Code cleanup: make a lot of methods static and remove some unnecessary interface implements and casts.

This commit is contained in:
elcnesh
2014-12-10 18:40:19 +00:00
parent 5055ed4d2b
commit 6de61cb9a6
10 changed files with 30 additions and 58 deletions

View File

@@ -185,9 +185,9 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
}
}
private PaperCard getFirstWithImage(Collection<PaperCard> cards) {
private static PaperCard getFirstWithImage(final Collection<PaperCard> cards) {
//NOTE: this is written this way to avoid checking final card in list
Iterator<PaperCard> iterator = cards.iterator();
final Iterator<PaperCard> iterator = cards.iterator();
PaperCard pc = iterator.next();
while (iterator.hasNext()) {
if (pc.hasImage()) {

View File

@@ -17,13 +17,13 @@
*/
package forge.card;
import java.util.StringTokenizer;
import org.apache.commons.lang3.StringUtils;
import forge.card.mana.IParserManaCost;
import forge.card.mana.ManaCost;
import forge.card.mana.ManaCostShard;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.StringTokenizer;
/**
* A collection of methods containing full
@@ -65,7 +65,7 @@ public final class CardRules implements ICardCharacteristics {
colorIdentity = newRules.colorIdentity;
}
private byte calculateColorIdentity(ICardFace face) {
private static byte calculateColorIdentity(final ICardFace face) {
byte res = face.getColor().getColor();
boolean isReminder = false;
boolean isSymbol = false;
@@ -154,7 +154,7 @@ public final class CardRules implements ICardCharacteristics {
}
}
private boolean canCastFace(ICardFace face, byte colorCode) {
private static boolean canCastFace(final ICardFace face, final byte colorCode) {
if (face.getManaCost().isNoCost()) {
//if card face has no cost, assume castable only by mana of its defined color
return face.getColor().hasNoColorsExcept(colorCode);
@@ -214,22 +214,6 @@ public final class CardRules implements ICardCharacteristics {
public String getPictureUrl(boolean backface ) { return backface ? dlUrlOtherSide : dlUrl; }
public void setDlUrls(String[] dlUrls) { this.dlUrl = dlUrls[0]; this.dlUrlOtherSide = dlUrls[1]; }
public final List<String> getReplacements() {
return null;
}
public final List<String> getTriggers() {
return null;
}
public final List<String> getStaticAbilities() {
return null;
}
public final List<String> getAbilities() {
return null;
}
public ColorSet getColorIdentity() {
return colorIdentity;
}

View File

@@ -248,7 +248,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
return subtypes.contains(creatureType) || subtypes.contains("AllCreatureTypes");
}
private String toMixedCase(final String s) {
private static String toMixedCase(final String s) {
if (s.equals("")) {
return s;
}

View File

@@ -194,7 +194,7 @@ public enum DeckFormat {
return null;
}
public String getPlaneSectionConformanceProblem(CardPool planes) {
public static String getPlaneSectionConformanceProblem(final CardPool planes) {
//Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
if (planes == null || planes.countAll() < 10) {
return "should have at least 10 planes";
@@ -214,7 +214,7 @@ public enum DeckFormat {
return null;
}
public String getSchemeSectionConformanceProblem(CardPool schemes) {
public static String getSchemeSectionConformanceProblem(final CardPool schemes) {
//Must contain at least 20 schemes, max 2 of each.
if (schemes == null || schemes.countAll() < 20) {
return "must contain at least 20 schemes";

View File

@@ -88,7 +88,7 @@ public class DeckStorage extends StorageReaderFolder<Deck> implements IItemSeria
return result;
}
private void adjustFileLocation(final File file, final Deck result) {
private static void adjustFileLocation(final File file, final Deck result) {
if (result == null) {
file.delete();
} else {

View File

@@ -272,7 +272,7 @@ public final class NameGenerator {
}
/** Generates a specified number of random names. */
public List<String> getRandomNames(int generateAmount, final List<String> excludeNames) {
public static List<String> getRandomNames(final int generateAmount, final List<String> excludeNames) {
usedNames = excludeNames;
final List<String> names = new ArrayList<String>(generateAmount);
for (int i = 0; i < generateAmount; i++) {