From d9eea3343038ac1016cbb3adcebca0934b3579a3 Mon Sep 17 00:00:00 2001 From: slapshot5 Date: Wed, 31 Aug 2011 07:54:18 +0000 Subject: [PATCH] a few Checkstyle fixes --- src/main/java/forge/CardFilter.java | 102 ++++++++++++++-------------- src/main/java/forge/Card_Color.java | 29 ++++---- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/main/java/forge/CardFilter.java b/src/main/java/forge/CardFilter.java index 20f95a99c1b..df8f7b57ea7 100644 --- a/src/main/java/forge/CardFilter.java +++ b/src/main/java/forge/CardFilter.java @@ -27,8 +27,7 @@ public class CardFilter { * @param substring a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public CardList cardListNameFilter(Iterable toBeFiltered, String substring) - { + public CardList cardListNameFilter(Iterable toBeFiltered, String substring) { String s; CardList listFilter = new CardList(); @@ -48,23 +47,23 @@ public class CardFilter { /** *

CardListTextFilter.

* - * TODO: style: rename this method so it starts with a lowercase letter + * TODO style: rename this method so it starts with a lowercase letter * * @param all a {@link forge.CardList} object. * @param name a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public CardList CardListTextFilter(CardList all, String name) { - Card CardName; + public final CardList CardListTextFilter(CardList all, String name) { + Card cardName; String s; s = ""; CardList listFilter = new CardList(); for (int i = 0; i < all.size(); i++) { - CardName = all.getCard(i); - s = CardName.getText().toLowerCase(); + cardName = all.getCard(i); + s = cardName.getText().toLowerCase(); if (s.indexOf(name.toLowerCase()) >= 0) { - listFilter.add(CardName); + listFilter.add(cardName); } @@ -77,13 +76,13 @@ public class CardFilter { /** *

CardListColorFilter.

* - * TODO: style: rename this method so it starts with a lowercase letter + * TODO style: rename this method so it starts with a lowercase letter * * @param all a {@link forge.CardList} object. * @param name a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public CardList CardListColorFilter(CardList all, String name) { + public final CardList CardListColorFilter(CardList all, String name) { Card CardName = new Card(); CardList listFilter = new CardList(); @@ -153,7 +152,7 @@ public class CardFilter { /** *

CardListTypeFilter.

* - * TODO: style: rename this method so it starts with a lowercase letter + * TODO style: rename this method so it starts with a lowercase letter * * @param all a {@link forge.CardList} object. * @param name a {@link java.lang.String} object. @@ -239,33 +238,33 @@ public class CardFilter { /** * Filter a sequence Generator of cards by rarity. * - * @param inputGenerator the sequence to filter (at a later time); must + * @param inputGenerator the sequence to filter (at a later time); must * not be null * - * @param rarity a valid value for Card.getSVar("Rarity"); must not be + * @param rarity a valid value for Card.getSVar("Rarity"); must not be * null. If equal to Constant.Rarity.Rare, the result will also contain * mythic cards. * * @return a sequence Generator whose cards only have the given rarity */ - public static Generator getRarity(Generator inputGenerator, final String rarity) { + public static Generator getRarity(final Generator inputGenerator, final String rarity) { UtilFunctions.checkNotNull("inputGenerator", inputGenerator); UtilFunctions.checkNotNull("rarity", rarity); - Lambda1 predicate = new Lambda1() { - public Boolean apply(Card c) { + Lambda1 predicate = new Lambda1() { + public Boolean apply(final Card c) { if (c == null) { return false; } // TODO spin off Mythic from Rare when the time comes String r = c.getSVar("Rarity"); - return (r != null && - (r.equals(rarity) || - rarity.equals(Constant.Rarity.Rare) && r.equals(Constant.Rarity.Mythic))); + return (r != null + && (r.equals(rarity) || rarity.equals(Constant.Rarity.Rare) + && r.equals(Constant.Rarity.Mythic))); } }; - + return GeneratorFunctions.filterGenerator(predicate, inputGenerator); } @@ -280,13 +279,14 @@ public class CardFilter { * @return a list of Cards that meet the filtering criteria; may be empty, * but never null */ - public static CardList filter(Iterable iterable, CardListFilter filt) { + public static CardList filter(final Iterable iterable, final CardListFilter filt) { CardList result = new CardList(); - for (Card card : iterable) + for (Card card : iterable) { if (filt.addCard(card)) { - result.add(card); + result.add(card); } - + } + return result; } @@ -304,32 +304,31 @@ public class CardFilter { * @return a new Generator containing cards only of the desired color or * multicolored cards. */ - public static Generator getColor(Generator inputGenerator, final String cardColor) - { - UtilFunctions.checkNotNull("inputGenerator", inputGenerator); - UtilFunctions.checkNotNull("cardColor", cardColor); + public static Generator getColor(final Generator inputGenerator, final String cardColor) { + UtilFunctions.checkNotNull("inputGenerator", inputGenerator); + UtilFunctions.checkNotNull("cardColor", cardColor); - final boolean weWantMulticolor = cardColor.equals("Multicolor"); - - Lambda1 predicate = new Lambda1() { - public Boolean apply(Card c) { - if (c == null) { - return false; - } - - if (weWantMulticolor && c.getColor() != null && c.getColor().size() > 1) { - return true; - } - else if (c.isColor(cardColor) && c.getColor() != null && c.getColor().size() == 1) { - return true; - } + final boolean weWantMulticolor = cardColor.equals("Multicolor"); - return false; - } - }; - - return GeneratorFunctions.filterGenerator(predicate, inputGenerator); - }//getColor() + Lambda1 predicate = new Lambda1() { + public Boolean apply(final Card c) { + if (c == null) { + return false; + } + + if (weWantMulticolor && c.getColor() != null && c.getColor().size() > 1) { + return true; + } + else if (c.isColor(cardColor) && c.getColor() != null && c.getColor().size() == 1) { + return true; + } + + return false; + } + }; + + return GeneratorFunctions.filterGenerator(predicate, inputGenerator); + } //getColor() /** * Filter a Generator of cards so that it contains only the ones that exist in certain sets. @@ -340,13 +339,13 @@ public class CardFilter { * * @return a {@link forge.CardList} object. */ - public static Generator getSets(Generator inputGenerator, final List sets) + public static Generator getSets(final Generator inputGenerator, final List sets) { UtilFunctions.checkNotNull("inputGenerator", inputGenerator); UtilFunctions.checkNotNull("sets", sets); Lambda1 predicate = new Lambda1() { - public Boolean apply(Card c) { + public Boolean apply(final Card c) { if (c == null) { return false; } @@ -362,7 +361,6 @@ public class CardFilter { }; return GeneratorFunctions.filterGenerator(predicate, inputGenerator); - }//getSets(Generator,ArrayList) - + } //getSets(Generator,ArrayList) } diff --git a/src/main/java/forge/Card_Color.java b/src/main/java/forge/Card_Color.java index a0314da0add..0f3d2f51594 100644 --- a/src/main/java/forge/Card_Color.java +++ b/src/main/java/forge/Card_Color.java @@ -21,7 +21,7 @@ public class Card_Color { * * @return a boolean. */ - public boolean getAdditional() { + public final boolean getAdditional() { return additional; } @@ -33,12 +33,12 @@ public class Card_Color { * * @return a long. */ - public long getStamp() { + public final long getStamp() { return stamp; } /** - * Constant timeStamp=0 + * Constant timeStamp=0. */ private static long timeStamp = 0; @@ -59,14 +59,15 @@ public class Card_Color { * @param addToColors a boolean. * @param baseColor a boolean. */ - Card_Color(ManaCost mc, Card c, boolean addToColors, boolean baseColor) { + Card_Color(final ManaCost mc, final Card c, final boolean addToColors, final boolean baseColor) { additional = addToColors; col = Color.ConvertManaCostToColor(mc); effectingCard = c; - if (baseColor) + if (baseColor) { stamp = 0; - else + } else { stamp = timeStamp; + } } /** @@ -74,7 +75,7 @@ public class Card_Color { * * @param c a {@link forge.Card} object. */ - public Card_Color(Card c) { + public Card_Color(final Card c) { col = Color.Colorless(); additional = false; stamp = 0; @@ -87,7 +88,7 @@ public class Card_Color { * @param s a {@link java.lang.String} object. * @return a boolean. */ - boolean addToCardColor(String s) { + final boolean addToCardColor(final String s) { Color c = Color.ConvertFromString(s); if (!col.contains(c)) { col.add(c); @@ -99,9 +100,10 @@ public class Card_Color { /** *

fixColorless.

*/ - void fixColorless() { - if (col.size() > 1 && col.contains(Color.Colorless)) + final void fixColorless() { + if (col.size() > 1 && col.contains(Color.Colorless)) { col.remove(Color.Colorless); + } } /** @@ -120,7 +122,7 @@ public class Card_Color { * @param time a long. * @return a boolean. */ - public boolean equals(String cost, Card c, boolean addToColors, long time) { + public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) { return effectingCard == c && addToColors == additional && stamp == time; } @@ -129,10 +131,11 @@ public class Card_Color { * * @return a {@link java.util.ArrayList} object. */ - public ArrayList toStringArray() { + public final ArrayList toStringArray() { ArrayList list = new ArrayList(); - for (Color c : col) + for (Color c : col) { list.add(c.toString()); + } return list; } }