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 {
protected boolean chosen;
protected boolean required;
protected final boolean required;
protected String choice;
protected String choiceKey;
protected Set<String> choices = new LinkedHashSet<>();

View file

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

View file

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

View file

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

View file

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

View file

@ -33,5 +33,5 @@ package mage.constants;
*/
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 {
protected int power;
protected int toughness;
protected final int power;
protected final int toughness;
public BoostCounter(int power, int toughness) {
this(power, toughness, 1);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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