From 752392fc46891330a632b845af6d2b5d012775cf Mon Sep 17 00:00:00 2001 From: vraskulin Date: Wed, 15 Feb 2017 19:23:12 +0300 Subject: [PATCH] Functional interfaces should be annotated as functional interfaces --- .../src/main/java/mage/client/util/Command.java | 2 +- .../src/main/java/mage/client/util/Listener.java | 1 + .../main/java/org/mage/card/arcane/TextboxRule.java | 1 + .../target/maven-archiver/pom.properties | 2 +- .../src/main/java/mage/server/SessionManager.java | 11 +++++------ .../src/main/java/mage/server/game/GameCallback.java | 1 + .../main/java/mage/server/game/GameController.java | 2 +- .../java/mage/server/services/FeedbackService.java | 1 + .../main/java/mage/server/services/LogService.java | 1 + Mage/src/main/java/mage/MageItem.java | 1 + .../main/java/mage/abilities/condition/Condition.java | 1 + .../mage/abilities/costs/AdjustingSourceCosts.java | 2 ++ .../costs/mana/AlternateManaPaymentAbility.java | 1 + .../java/mage/abilities/mana/builder/Builder.java | 1 + .../mage/filter/predicate/ObjectPlayerPredicate.java | 1 + .../filter/predicate/ObjectSourcePlayerPredicate.java | 1 + .../main/java/mage/filter/predicate/Predicate.java | 1 + Mage/src/main/java/mage/game/Table.java | 1 + Mage/src/main/java/mage/game/events/Listener.java | 1 + Mage/src/main/java/mage/util/CircularList.java | 2 ++ Mage/src/main/java/mage/util/Copyable.java | 2 +- Mage/src/main/java/mage/util/functions/Function.java | 1 + 22 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/util/Command.java b/Mage.Client/src/main/java/mage/client/util/Command.java index 9e73ca89d1..4059ed2c37 100644 --- a/Mage.Client/src/main/java/mage/client/util/Command.java +++ b/Mage.Client/src/main/java/mage/client/util/Command.java @@ -3,7 +3,7 @@ package mage.client.util; /** * @author nantuko */ +@FunctionalInterface public interface Command { - void execute(); } diff --git a/Mage.Client/src/main/java/mage/client/util/Listener.java b/Mage.Client/src/main/java/mage/client/util/Listener.java index 6fb209b684..3564d1c2b5 100644 --- a/Mage.Client/src/main/java/mage/client/util/Listener.java +++ b/Mage.Client/src/main/java/mage/client/util/Listener.java @@ -34,6 +34,7 @@ import java.io.Serializable; * @author BetaSteward_at_googlemail.com * @param */ +@FunctionalInterface public interface Listener extends Serializable { void event(E event); diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java index 0e4b836042..093f541846 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java @@ -23,6 +23,7 @@ public class TextboxRule { // An attributed region in the text, which can be applied to an // attributed string. + @FunctionalInterface public interface AttributeRegion { void applyToAttributedString(AttributedString str, Font normal, Font italic); diff --git a/Mage.Server.Plugins/Mage.Game.CanadianHighlanderDuel/target/maven-archiver/pom.properties b/Mage.Server.Plugins/Mage.Game.CanadianHighlanderDuel/target/maven-archiver/pom.properties index 004569ce64..93d5e67cb6 100644 --- a/Mage.Server.Plugins/Mage.Game.CanadianHighlanderDuel/target/maven-archiver/pom.properties +++ b/Mage.Server.Plugins/Mage.Game.CanadianHighlanderDuel/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Sun Feb 05 18:32:22 AEDT 2017 +#Wed Feb 15 19:18:14 MSK 2017 version=1.4.21 groupId=org.mage artifactId=mage-game-canadianhighlanderduel diff --git a/Mage.Server/src/main/java/mage/server/SessionManager.java b/Mage.Server/src/main/java/mage/server/SessionManager.java index 5692f0e0f3..ddd7527383 100644 --- a/Mage.Server/src/main/java/mage/server/SessionManager.java +++ b/Mage.Server/src/main/java/mage/server/SessionManager.java @@ -37,6 +37,8 @@ import mage.players.net.UserData; import org.apache.log4j.Logger; import org.jboss.remoting.callback.InvokerCallbackHandler; +import javax.annotation.Nonnull; + /** * @author BetaSteward_at_googlemail.com */ @@ -51,10 +53,7 @@ public class SessionManager { private final ConcurrentHashMap sessions = new ConcurrentHashMap<>(); - public Session getSession(String sessionId) { - if (sessionId == null) { - return null; - } + public Session getSession(@Nonnull String sessionId) { Session session = sessions.get(sessionId); if (session != null && session.getUserId() != null && UserManager.getInstance().getUser(session.getUserId()) == null) { logger.error("User for session " + sessionId + " with userId " + session.getUserId() + " is missing. Session removed."); @@ -209,11 +208,11 @@ public class SessionManager { return false; } - public boolean isValidSession(String sessionId) { + public boolean isValidSession(@Nonnull String sessionId) { return sessions.containsKey(sessionId); } - public Optional getUser(String sessionId) { + public Optional getUser(@Nonnull String sessionId) { Session session = sessions.get(sessionId); if (session != null) { return UserManager.getInstance().getUser(sessions.get(sessionId).getUserId()); diff --git a/Mage.Server/src/main/java/mage/server/game/GameCallback.java b/Mage.Server/src/main/java/mage/server/game/GameCallback.java index af13a0631a..f0073b3dba 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameCallback.java +++ b/Mage.Server/src/main/java/mage/server/game/GameCallback.java @@ -34,6 +34,7 @@ import mage.MageException; * * @author BetaSteward_at_googlemail.com */ +@FunctionalInterface public interface GameCallback { void gameResult(String result) throws MageException; diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 97a7fb25d6..908b330707 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -978,8 +978,8 @@ public class GameController implements GameCallback { } } + @FunctionalInterface interface Command { - void execute(UUID player); } diff --git a/Mage.Server/src/main/java/mage/server/services/FeedbackService.java b/Mage.Server/src/main/java/mage/server/services/FeedbackService.java index c3fe97a0ad..f8a2463e6c 100644 --- a/Mage.Server/src/main/java/mage/server/services/FeedbackService.java +++ b/Mage.Server/src/main/java/mage/server/services/FeedbackService.java @@ -5,6 +5,7 @@ package mage.server.services; * * @author noxx */ +@FunctionalInterface public interface FeedbackService { /** diff --git a/Mage.Server/src/main/java/mage/server/services/LogService.java b/Mage.Server/src/main/java/mage/server/services/LogService.java index 96b8ef500e..b0edcdfba4 100644 --- a/Mage.Server/src/main/java/mage/server/services/LogService.java +++ b/Mage.Server/src/main/java/mage/server/services/LogService.java @@ -5,6 +5,7 @@ package mage.server.services; * * @author noxx */ +@FunctionalInterface public interface LogService { /** diff --git a/Mage/src/main/java/mage/MageItem.java b/Mage/src/main/java/mage/MageItem.java index bcbf51049c..ff79342a09 100644 --- a/Mage/src/main/java/mage/MageItem.java +++ b/Mage/src/main/java/mage/MageItem.java @@ -35,6 +35,7 @@ import java.util.UUID; * * @author BetaSteward_at_googlemail.com */ +@FunctionalInterface public interface MageItem extends Serializable { UUID getId(); diff --git a/Mage/src/main/java/mage/abilities/condition/Condition.java b/Mage/src/main/java/mage/abilities/condition/Condition.java index 62c79e5144..341df6400c 100644 --- a/Mage/src/main/java/mage/abilities/condition/Condition.java +++ b/Mage/src/main/java/mage/abilities/condition/Condition.java @@ -10,6 +10,7 @@ import mage.game.Game; * * @author nantuko, noxx */ +@FunctionalInterface public interface Condition extends Serializable { public enum ComparisonType { diff --git a/Mage/src/main/java/mage/abilities/costs/AdjustingSourceCosts.java b/Mage/src/main/java/mage/abilities/costs/AdjustingSourceCosts.java index a9197bd46d..c8056d276a 100644 --- a/Mage/src/main/java/mage/abilities/costs/AdjustingSourceCosts.java +++ b/Mage/src/main/java/mage/abilities/costs/AdjustingSourceCosts.java @@ -1,3 +1,4 @@ +/* /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * @@ -38,6 +39,7 @@ import mage.game.Game; * * @author nantuko */ +@FunctionalInterface public interface AdjustingSourceCosts { void adjustCosts(Ability ability, Game game); } diff --git a/Mage/src/main/java/mage/abilities/costs/mana/AlternateManaPaymentAbility.java b/Mage/src/main/java/mage/abilities/costs/mana/AlternateManaPaymentAbility.java index 9091171cbe..9316d8c49c 100644 --- a/Mage/src/main/java/mage/abilities/costs/mana/AlternateManaPaymentAbility.java +++ b/Mage/src/main/java/mage/abilities/costs/mana/AlternateManaPaymentAbility.java @@ -38,6 +38,7 @@ import mage.game.Game; * * @author LevelX2 */ +@FunctionalInterface public interface AlternateManaPaymentAbility { /** * Adds the special action to the state, that allows the user to do the alternate mana payment diff --git a/Mage/src/main/java/mage/abilities/mana/builder/Builder.java b/Mage/src/main/java/mage/abilities/mana/builder/Builder.java index 9cb05eeb1e..f55166543a 100644 --- a/Mage/src/main/java/mage/abilities/mana/builder/Builder.java +++ b/Mage/src/main/java/mage/abilities/mana/builder/Builder.java @@ -32,6 +32,7 @@ import java.io.Serializable; /** * @author noxx */ +@FunctionalInterface public interface Builder extends Serializable { T build(Object... options); diff --git a/Mage/src/main/java/mage/filter/predicate/ObjectPlayerPredicate.java b/Mage/src/main/java/mage/filter/predicate/ObjectPlayerPredicate.java index c192273d00..306ccf19f0 100644 --- a/Mage/src/main/java/mage/filter/predicate/ObjectPlayerPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/ObjectPlayerPredicate.java @@ -32,5 +32,6 @@ package mage.filter.predicate; * @author North * @param */ +@FunctionalInterface public interface ObjectPlayerPredicate extends Predicate { } diff --git a/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayerPredicate.java b/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayerPredicate.java index f9fc52cef1..cc706c5dde 100644 --- a/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayerPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/ObjectSourcePlayerPredicate.java @@ -32,5 +32,6 @@ package mage.filter.predicate; * @author North * @param */ +@FunctionalInterface public interface ObjectSourcePlayerPredicate extends ObjectPlayerPredicate { } diff --git a/Mage/src/main/java/mage/filter/predicate/Predicate.java b/Mage/src/main/java/mage/filter/predicate/Predicate.java index 82ad99084e..9dd1051a40 100644 --- a/Mage/src/main/java/mage/filter/predicate/Predicate.java +++ b/Mage/src/main/java/mage/filter/predicate/Predicate.java @@ -36,6 +36,7 @@ import mage.game.Game; * @author North * @param */ +@FunctionalInterface public interface Predicate extends Serializable { /** * Returns the result of applying this predicate to {@code input}. This method is generally diff --git a/Mage/src/main/java/mage/game/Table.java b/Mage/src/main/java/mage/game/Table.java index 5753566aa7..1a019a24a7 100644 --- a/Mage/src/main/java/mage/game/Table.java +++ b/Mage/src/main/java/mage/game/Table.java @@ -64,6 +64,7 @@ public class Table implements Serializable { private Tournament tournament; private TableRecorder recorder; + @FunctionalInterface public interface TableRecorder { void record(Table table); } diff --git a/Mage/src/main/java/mage/game/events/Listener.java b/Mage/src/main/java/mage/game/events/Listener.java index 696526e186..54dab1f707 100644 --- a/Mage/src/main/java/mage/game/events/Listener.java +++ b/Mage/src/main/java/mage/game/events/Listener.java @@ -34,6 +34,7 @@ import java.io.Serializable; * * @author BetaSteward_at_googlemail.com */ +@FunctionalInterface public interface Listener extends Serializable { void event(E event); } diff --git a/Mage/src/main/java/mage/util/CircularList.java b/Mage/src/main/java/mage/util/CircularList.java index 7a131d4d44..cc7cad2e4a 100644 --- a/Mage/src/main/java/mage/util/CircularList.java +++ b/Mage/src/main/java/mage/util/CircularList.java @@ -27,6 +27,8 @@ */ package mage.util; + + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; diff --git a/Mage/src/main/java/mage/util/Copyable.java b/Mage/src/main/java/mage/util/Copyable.java index e1d0adc1aa..32233a3937 100644 --- a/Mage/src/main/java/mage/util/Copyable.java +++ b/Mage/src/main/java/mage/util/Copyable.java @@ -32,7 +32,7 @@ package mage.util; * * @author BetaSteward_at_googlemail.com */ +@FunctionalInterface public interface Copyable { - T copy(); } diff --git a/Mage/src/main/java/mage/util/functions/Function.java b/Mage/src/main/java/mage/util/functions/Function.java index 53e2ffe436..bbb6608e9e 100644 --- a/Mage/src/main/java/mage/util/functions/Function.java +++ b/Mage/src/main/java/mage/util/functions/Function.java @@ -30,6 +30,7 @@ package mage.util.functions; /** * @author nantuko */ +@FunctionalInterface public interface Function { X apply(Y in); }