Refactoring

See github line by line comments in 'File changed'
This commit is contained in:
vraskulin 2016-12-29 15:38:22 +03:00
parent c526306c5b
commit 01bb9572e9
21 changed files with 31 additions and 34 deletions

View file

@ -41,7 +41,7 @@ import java.util.Set;
public class ChoiceImpl implements Choice, Serializable { public class ChoiceImpl implements Choice, Serializable {
protected boolean chosen; protected boolean chosen;
protected boolean required; protected final boolean required;
protected String choice; protected String choice;
protected String choiceKey; protected String choiceKey;
protected Set<String> choices = new LinkedHashSet<>(); protected Set<String> choices = new LinkedHashSet<>();

View file

@ -48,5 +48,5 @@ public enum DependencyType {
BecomePlains, BecomePlains,
BecomeSwamp, BecomeSwamp,
EnchantmentAddingRemoving, EnchantmentAddingRemoving,
LooseDefenderEffect; LooseDefenderEffect
} }

View file

@ -24,4 +24,4 @@ public enum ManaType {
public String toString() { public String toString() {
return text; return text;
} }
}; }

View file

@ -19,8 +19,8 @@ public enum MatchTimeLimit {
MIN__90(5400, "90 Minutes"), MIN__90(5400, "90 Minutes"),
MIN_120(7200, "120 Minutes"); MIN_120(7200, "120 Minutes");
private int matchSeconds; private final int matchSeconds;
private String name; private final String name;
MatchTimeLimit(int matchSeconds, String name) { MatchTimeLimit(int matchSeconds, String name) {
this.matchSeconds = matchSeconds; this.matchSeconds = matchSeconds;

View file

@ -9,7 +9,7 @@ public enum RangeOfInfluence {
TWO(2), TWO(2),
ALL(0); ALL(0);
private int range; private final int range;
RangeOfInfluence(int range) { RangeOfInfluence(int range) {
this.range = range; this.range = range;

View file

@ -33,5 +33,5 @@ package mage.constants;
*/ */
public enum SetTargetPointer { public enum SetTargetPointer {
NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER; NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER
} }

View file

@ -34,8 +34,8 @@ package mage.counters;
*/ */
public class BoostCounter extends Counter { public class BoostCounter extends Counter {
protected int power; protected final int power;
protected int toughness; protected final int toughness;
public BoostCounter(int power, int toughness) { public BoostCounter(int power, int toughness) {
this(power, toughness, 1); this(power, toughness, 1);

View file

@ -158,10 +158,7 @@ public class Counter implements Serializable {
Counter counter = (Counter) o; Counter counter = (Counter) o;
if (count != counter.count) { return count == counter.count && !(name != null ? !name.equals(counter.name) : counter.name != null);
return false;
}
return !(name != null ? !name.equals(counter.name) : counter.name != null);
} }

View file

@ -123,7 +123,7 @@ public enum CounterType {
private final String name; private final String name;
private CounterType(String name) { CounterType(String name) {
this.name = name; this.name = name;
} }

View file

@ -31,7 +31,7 @@ public abstract class Designation implements MageObject {
private static List emptyList = new ArrayList(); private static List emptyList = new ArrayList();
private static ObjectColor emptyColor = new ObjectColor(); private static ObjectColor emptyColor = new ObjectColor();
private static ManaCosts emptyCost = new ManaCostsImpl(); private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl();
private String name; private String name;
private UUID id; private UUID id;

View file

@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
*/ */
public class FilterControlledCreatureInPlay extends FilterImpl<Object> implements FilterInPlay<Object> { public class FilterControlledCreatureInPlay extends FilterImpl<Object> implements FilterInPlay<Object> {
protected FilterCreaturePermanent creatureFilter; protected final FilterCreaturePermanent creatureFilter;
public FilterControlledCreatureInPlay() { public FilterControlledCreatureInPlay() {
this("creature"); this("creature");

View file

@ -43,7 +43,7 @@ import mage.players.Player;
public class FilterCreatureOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> { public class FilterCreatureOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
protected FilterCreaturePermanent creatureFilter; protected FilterCreaturePermanent creatureFilter;
protected FilterPlayer playerFilter; protected final FilterPlayer playerFilter;
public FilterCreatureOrPlayer() { public FilterCreatureOrPlayer() {
this("creature or player"); this("creature or player");

View file

@ -42,8 +42,8 @@ import mage.players.Player;
*/ */
public class FilterPermanentOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> { public class FilterPermanentOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
protected FilterPermanent permanentFilter; protected final FilterPermanent permanentFilter;
protected FilterPlayer playerFilter; protected final FilterPlayer playerFilter;
public FilterPermanentOrPlayer() { public FilterPermanentOrPlayer() {
this("player or permanent"); this("player or permanent");

View file

@ -46,8 +46,8 @@ import mage.players.Player;
*/ */
public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> { public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
protected FilterPlaneswalkerPermanent planeswalkerFilter; protected final FilterPlaneswalkerPermanent planeswalkerFilter;
protected FilterPlayer playerFilter; protected final FilterPlayer playerFilter;
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) { public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
super("planeswalker or player"); super("planeswalker or player");

View file

@ -36,8 +36,8 @@ import java.util.UUID;
*/ */
public class ObjectPlayer<T> { public class ObjectPlayer<T> {
protected T object; protected final T object;
protected UUID playerId; protected final UUID playerId;
public ObjectPlayer(T object, UUID playerId) { public ObjectPlayer(T object, UUID playerId) {
this.object = object; this.object = object;

View file

@ -36,7 +36,7 @@ import java.util.UUID;
*/ */
public class ObjectSourcePlayer<T> extends ObjectPlayer<T> { public class ObjectSourcePlayer<T> extends ObjectPlayer<T> {
protected UUID sourceId; protected final UUID sourceId;
public ObjectSourcePlayer(T object, UUID sourceId, UUID playerId) { public ObjectSourcePlayer(T object, UUID sourceId, UUID playerId) {
super(object, playerId); super(object, playerId);

View file

@ -168,8 +168,8 @@ public final class Predicates {
@Override @Override
public boolean apply(T t, Game game) { public boolean apply(T t, Game game) {
for (int i = 0; i < components.size(); i++) { for (Predicate<? super T> component : components) {
if (!components.get(i).apply(t, game)) { if (!component.apply(t, game)) {
return false; return false;
} }
} }
@ -196,8 +196,8 @@ public final class Predicates {
@Override @Override
public boolean apply(T t, Game game) { public boolean apply(T t, Game game) {
for (int i = 0; i < components.size(); i++) { for (Predicate<? super T> component : components) {
if (components.get(i).apply(t, game)) { if (component.apply(t, game)) {
return true; return true;
} }
} }
@ -244,8 +244,8 @@ public final class Predicates {
private static String commaJoin(List components) { private static String commaJoin(List components) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < components.size(); i++) { for (Object component : components) {
sb.append(components.get(i).toString()); sb.append(component.toString());
} }
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
return sb.toString(); return sb.toString();

View file

@ -38,7 +38,7 @@ import mage.game.Game;
*/ */
public class FromSetPredicate<T extends MageItem> implements Predicate<T> { public class FromSetPredicate<T extends MageItem> implements Predicate<T> {
protected Set<UUID> set; protected final Set<UUID> set;
public FromSetPredicate(Set<UUID> set) { public FromSetPredicate(Set<UUID> set) {
this.set = set; this.set = set;

View file

@ -39,7 +39,7 @@ import mage.game.permanent.Permanent;
*/ */
public class AttachedToPredicate implements Predicate<Permanent> { public class AttachedToPredicate implements Predicate<Permanent> {
private FilterPermanent filter; private final FilterPermanent filter;
public AttachedToPredicate(FilterPermanent filter) { public AttachedToPredicate(FilterPermanent filter) {
this.filter = filter; this.filter = filter;

View file

@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
public class ControllerControlsIslandPredicate implements Predicate<Permanent> { public class ControllerControlsIslandPredicate implements Predicate<Permanent> {
public static final FilterLandPermanent filter = new FilterLandPermanent("Island"); public static final FilterLandPermanent filter = new FilterLandPermanent("Island");
{ static {
filter.add(new SubtypePredicate("Island")); filter.add(new SubtypePredicate("Island"));
} }

View file

@ -51,6 +51,6 @@ public class PermanentIdPredicate implements Predicate<Permanent> {
@Override @Override
public String toString() { public String toString() {
return new StringBuilder("PermanentId(").append(permanentId).append(")").toString() ; return "PermanentId(" + permanentId + ")";
} }
} }