From 4a2a40ae2d6985c274e569c72ad8a18575b85a9d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 12 Mar 2014 17:41:56 +0100 Subject: [PATCH] Minor formatting. --- .../sets/avacynrestored/CavernOfSouls.java | 1 + .../mage/sets/dragonsmaze/ArmedDangerous.java | 4 -- .../src/mage/sets/iceage/KjeldoranDead.java | 1 + Mage/src/mage/abilities/SpecialActions.java | 5 ++- Mage/src/mage/filter/Filter.java | 5 ++- Mage/src/mage/filter/FilterCard.java | 12 +++--- Mage/src/mage/filter/FilterImpl.java | 3 +- Mage/src/mage/filter/FilterObject.java | 5 ++- Mage/src/mage/filter/FilterPlayer.java | 6 +-- .../mage/filter/predicate/ObjectPlayer.java | 2 + .../predicate/ObjectPlayerPredicate.java | 1 + .../filter/predicate/ObjectSourcePlayer.java | 1 + Mage/src/mage/filter/predicate/Predicate.java | 4 ++ .../src/mage/filter/predicate/Predicates.java | 39 +++++++++++++++---- .../predicate/other/CardTextPredicate.java | 4 +- 15 files changed, 64 insertions(+), 29 deletions(-) diff --git a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java index 9a5db0da3b8..f14c88853b3 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java @@ -189,6 +189,7 @@ class CavernOfSoulsWatcher extends WatcherImpl { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.MANA_PAYED) { MageObject object = game.getObject(event.getSourceId()); + // TODO: Replace identification by name by better method that also works if ability is copied from other land with other name if (object != null && object.getName().equals("Cavern of Souls") && event.getFlag()) { spells.add(event.getTargetId()); } diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/ArmedDangerous.java b/Mage.Sets/src/mage/sets/dragonsmaze/ArmedDangerous.java index e68f15cdccc..5e71f72937c 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/ArmedDangerous.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/ArmedDangerous.java @@ -32,10 +32,6 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.combat.MustBeBlockedByAllSourceEffect; import mage.abilities.effects.common.combat.MustBeBlockedByAllTargetEffect; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.abilities.effects.common.continious.GainAbilityTargetEffect; diff --git a/Mage.Sets/src/mage/sets/iceage/KjeldoranDead.java b/Mage.Sets/src/mage/sets/iceage/KjeldoranDead.java index 355cbec8a6a..b8f052ab2f2 100644 --- a/Mage.Sets/src/mage/sets/iceage/KjeldoranDead.java +++ b/Mage.Sets/src/mage/sets/iceage/KjeldoranDead.java @@ -34,6 +34,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.RegenerateSourceEffect; +import mage.abilities.effects.common.SacrificeControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; diff --git a/Mage/src/mage/abilities/SpecialActions.java b/Mage/src/mage/abilities/SpecialActions.java index 15b711e6436..f0c70e1f945 100644 --- a/Mage/src/mage/abilities/SpecialActions.java +++ b/Mage/src/mage/abilities/SpecialActions.java @@ -44,10 +44,11 @@ public class SpecialActions extends AbilitiesImpl { } public LinkedHashMap getControlledBy(UUID controllerId) { - LinkedHashMap controlledBy = new LinkedHashMap(); + LinkedHashMap controlledBy = new LinkedHashMap<>(); for (SpecialAction action: this) { - if (action.getControllerId().equals(controllerId)) + if (action.getControllerId().equals(controllerId)) { controlledBy.put(action.id, action); + } } return controlledBy; } diff --git a/Mage/src/mage/filter/Filter.java b/Mage/src/mage/filter/Filter.java index 90d0c228457..829c5a835b0 100644 --- a/Mage/src/mage/filter/Filter.java +++ b/Mage/src/mage/filter/Filter.java @@ -29,6 +29,7 @@ package mage.filter; import java.io.Serializable; +import mage.MageObject; import mage.filter.predicate.Predicate; import mage.game.Game; @@ -36,6 +37,8 @@ import mage.game.Game; * * @author BetaSteward_at_googlemail.com * @author North + * + * @param */ public interface Filter extends Serializable { @@ -45,7 +48,7 @@ public interface Filter extends Serializable { Equal("=="), LessThan("<"); - private String text; + private final String text; ComparisonType(String text) { this.text = text; diff --git a/Mage/src/mage/filter/FilterCard.java b/Mage/src/mage/filter/FilterCard.java index db08ae6c743..131ca6e4910 100644 --- a/Mage/src/mage/filter/FilterCard.java +++ b/Mage/src/mage/filter/FilterCard.java @@ -48,7 +48,7 @@ import mage.game.Game; public class FilterCard extends FilterObject { private static final long serialVersionUID = 1L; - protected List>> extraPredicates = new ArrayList>>(); + protected List>> extraPredicates = new ArrayList<>(); public FilterCard() { super("card"); @@ -60,7 +60,7 @@ public class FilterCard extends FilterObject { public FilterCard(FilterCard filter) { super(filter); - this.extraPredicates = new ArrayList>>(filter.extraPredicates); + this.extraPredicates = new ArrayList<>(filter.extraPredicates); } //20130711 708.6c @@ -87,8 +87,8 @@ public class FilterCard extends FilterObject { if (!this.match(card, game)) { return false; } - - return Predicates.and(extraPredicates).apply(new ObjectPlayer(card, playerId), game); + + return Predicates.and(extraPredicates).apply(new ObjectPlayer<>(card, playerId), game); } public boolean match(Card card, UUID sourceId, UUID playerId, Game game) { @@ -96,7 +96,7 @@ public class FilterCard extends FilterObject { return false; } - return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(card, sourceId, playerId), game); + return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer<>(card, sourceId, playerId), game); } public void add(ObjectPlayerPredicate predicate) { @@ -104,7 +104,7 @@ public class FilterCard extends FilterObject { } public Set filter(Set cards, Game game) { - Set filtered = new HashSet(); + Set filtered = new HashSet<>(); for (Card card : cards) { if (match(card, game)) { filtered.add(card); diff --git a/Mage/src/mage/filter/FilterImpl.java b/Mage/src/mage/filter/FilterImpl.java index ecb3f9ee923..4acf76dd43f 100644 --- a/Mage/src/mage/filter/FilterImpl.java +++ b/Mage/src/mage/filter/FilterImpl.java @@ -30,6 +30,7 @@ package mage.filter; import java.util.ArrayList; import java.util.List; +import mage.MageObject; import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicates; import mage.game.Game; @@ -52,7 +53,7 @@ public abstract class FilterImpl implements Filter { this.message = name; } - public FilterImpl(FilterImpl filter) { + public FilterImpl(FilterImpl filter) { this.message = filter.message; this.predicates = new ArrayList<>(filter.predicates); } diff --git a/Mage/src/mage/filter/FilterObject.java b/Mage/src/mage/filter/FilterObject.java index 88cbe405a35..9d2034279ae 100644 --- a/Mage/src/mage/filter/FilterObject.java +++ b/Mage/src/mage/filter/FilterObject.java @@ -33,19 +33,20 @@ import mage.MageObject; /** * * @author North + * @param */ public class FilterObject extends FilterImpl { @Override public FilterObject copy() { - return new FilterObject(this); + return new FilterObject<>(this); } public FilterObject(String name) { super(name); } - public FilterObject(FilterObject filter) { + public FilterObject(FilterObject filter) { super(filter); } } diff --git a/Mage/src/mage/filter/FilterPlayer.java b/Mage/src/mage/filter/FilterPlayer.java index ef4890477ce..d6bf96ec0a0 100644 --- a/Mage/src/mage/filter/FilterPlayer.java +++ b/Mage/src/mage/filter/FilterPlayer.java @@ -45,7 +45,7 @@ import mage.players.Player; */ public class FilterPlayer extends FilterImpl { - protected List>> extraPredicates = new ArrayList>>(); + protected List>> extraPredicates = new ArrayList<>(); public FilterPlayer() { this("player"); @@ -57,10 +57,10 @@ public class FilterPlayer extends FilterImpl { public FilterPlayer(final FilterPlayer filter) { super(filter); - this.extraPredicates = new ArrayList>>(filter.extraPredicates); + this.extraPredicates = new ArrayList<>(filter.extraPredicates); } - public void add(ObjectPlayerPredicate predicate) { + public void add(ObjectPlayerPredicate> predicate) { extraPredicates.add(predicate); } diff --git a/Mage/src/mage/filter/predicate/ObjectPlayer.java b/Mage/src/mage/filter/predicate/ObjectPlayer.java index 7cb609a331c..c032c294b47 100644 --- a/Mage/src/mage/filter/predicate/ObjectPlayer.java +++ b/Mage/src/mage/filter/predicate/ObjectPlayer.java @@ -28,10 +28,12 @@ package mage.filter.predicate; import java.util.UUID; +import mage.MageObject; /** * * @author North + * @param */ public class ObjectPlayer { diff --git a/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java b/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java index 5fddeed0138..b5999c48da0 100644 --- a/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java +++ b/Mage/src/mage/filter/predicate/ObjectPlayerPredicate.java @@ -30,6 +30,7 @@ package mage.filter.predicate; /** * * @author North + * @param */ public interface ObjectPlayerPredicate extends Predicate { } diff --git a/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java b/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java index 2a7493da431..c2096b6d0cf 100644 --- a/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java +++ b/Mage/src/mage/filter/predicate/ObjectSourcePlayer.java @@ -32,6 +32,7 @@ import java.util.UUID; /** * * @author North + * @param */ public class ObjectSourcePlayer extends ObjectPlayer { diff --git a/Mage/src/mage/filter/predicate/Predicate.java b/Mage/src/mage/filter/predicate/Predicate.java index d5d577c6ea5..4fd8bb1eb2b 100644 --- a/Mage/src/mage/filter/predicate/Predicate.java +++ b/Mage/src/mage/filter/predicate/Predicate.java @@ -34,6 +34,7 @@ import mage.game.Game; * Determines a true or false value for a given input. * * @author North + * @param */ public interface Predicate extends Serializable { /** @@ -47,6 +48,9 @@ public interface Predicate extends Serializable { * predicate.apply(b)}. * * + * @param input + * @param game + * @return * @throws NullPointerException if {@code input} is null and this predicate does not accept null * arguments */ diff --git a/Mage/src/mage/filter/predicate/Predicates.java b/Mage/src/mage/filter/predicate/Predicates.java index e325464a384..d37d4322581 100644 --- a/Mage/src/mage/filter/predicate/Predicates.java +++ b/Mage/src/mage/filter/predicate/Predicates.java @@ -47,9 +47,12 @@ public final class Predicates { /** * Returns a predicate that evaluates to {@code true} if the given predicate evaluates to {@code false}. + * @param + * @param predicate + * @return */ public static Predicate not(Predicate predicate) { - return new NotPredicate(predicate); + return new NotPredicate<>(predicate); } /** @@ -57,9 +60,12 @@ public final class Predicates { * components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is * found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this * predicate. If {@code components} is empty, the returned predicate will always evaluate to {@code true}. + * @param + * @param components + * @return */ public static Predicate and(Iterable> components) { - return new AndPredicate(defensiveCopy(components)); + return new AndPredicate<>(defensiveCopy(components)); } /** @@ -67,18 +73,25 @@ public final class Predicates { * components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is * found. It defensively copies the array passed in, so future changes to it won't alter the behavior of this * predicate. If {@code components} is empty, the returned predicate will always evaluate to {@code true}. + * @param + * @param components + * @return */ public static Predicate and(Predicate... components) { - return new AndPredicate(defensiveCopy(components)); + return new AndPredicate<>(defensiveCopy(components)); } /** * Returns a predicate that evaluates to {@code true} if both of its components evaluate to {@code true}. The * components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is * found. + * @param + * @param first + * @param second + * @return */ public static Predicate and(Predicate first, Predicate second) { - return new AndPredicate(Predicates.asList(checkNotNull(first), checkNotNull(second))); + return new AndPredicate<>(Predicates.asList(checkNotNull(first), checkNotNull(second))); } /** @@ -86,9 +99,12 @@ public final class Predicates { * components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found. * It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate. * If {@code components} is empty, the returned predicate will always evaluate to {@code true}. + * @param + * @param components + * @return */ public static Predicate or(Iterable> components) { - return new OrPredicate(defensiveCopy(components)); + return new OrPredicate<>(defensiveCopy(components)); } /** @@ -96,17 +112,24 @@ public final class Predicates { * components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found. * It defensively copies the array passed in, so future changes to it won't alter the behavior of this predicate. If * {@code components} is empty, the returned predicate will always evaluate to {@code true}. + * @param + * @param components + * @return */ public static Predicate or(Predicate... components) { - return new OrPredicate(defensiveCopy(components)); + return new OrPredicate<>(defensiveCopy(components)); } /** * Returns a predicate that evaluates to {@code true} if either of its components evaluates to {@code true}. The * components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found. + * @param + * @param first + * @param second + * @return */ public static Predicate or(Predicate first, Predicate second) { - return new OrPredicate(Predicates.asList(first, second)); + return new OrPredicate<>(Predicates.asList(first, second)); } /** @@ -198,7 +221,7 @@ public final class Predicates { } static List defensiveCopy(Iterable iterable) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (T element : iterable) { list.add(checkNotNull(element)); } diff --git a/Mage/src/mage/filter/predicate/other/CardTextPredicate.java b/Mage/src/mage/filter/predicate/other/CardTextPredicate.java index 35a285c3407..547fab02ef6 100644 --- a/Mage/src/mage/filter/predicate/other/CardTextPredicate.java +++ b/Mage/src/mage/filter/predicate/other/CardTextPredicate.java @@ -27,9 +27,9 @@ */ package mage.filter.predicate.other; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import mage.cards.Card; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; import mage.filter.predicate.Predicate; import mage.game.Game;