From 2219d8d39bd2cdee41f67d6760dfadb90d132ed2 Mon Sep 17 00:00:00 2001 From: frigoref Date: Sun, 18 Aug 2024 00:20:33 +0200 Subject: [PATCH] I18n v2 (@NonNls + Locals for toLowerCase/toUpperCase) (#12840) * i18n_v2 #1 annotate I18n classes with @NonNls * i18n_v2 #2 annotate @NonNls with .-pattern (.*String .+ *= "\w+\.[A-Za-z]+[A-Za-z\.]*) * i18n_v2 #3 fix via @NonNls imports * i18n_v2 #4 add @NonNls to Strings based on review with pattern (.*String .* = .*\+.*") * i18n_v2 #5 add @NonNls import to AbstractConditionsAttachment.java AbstractImageFactory.java AutoPlacementFinder.java ClipPlayer.java CliProperties.java CommentPanel.java DownloadFile.java FileNameUtils.java FlagIconImageFactory.java GameParser.java GameRunner.java InGameLobbyWatcher.java MapData.java NodeBbForumPoster.java NotificationMessages.java ObjectiveProperties.java PoliticsText.java ProductionRepairPanel.java ProductionTabsProperties.java TooltipProperties.java UnitIconProperties.java UnitImageFactory.java * i18n_v2.1 #6 add @NonNls to Strings based on review with static-String-pattern (.*static final String .* = ") * i18n_v2.1 #7 add @NonNls and Locals to getUpperCase() calls (toUpperCase\()\) * i18n_v2.1 #7 add @NonNls and Locals to toLowerCase() or toUpperCase() calls (?@,;:\\\\\".\\[\\] \\x28\\p{Cntrl}]+"; - final String word = "(?:" + atom + "|" + quotedString + ")"; - final String subdomain = "(?:" + atom + "|\\[(?:[^\\[\\]\\\\]|\\\\\\p{ASCII})*\\])"; - final String domain = subdomain + "(?:\\." + subdomain + ")*"; - final String localPart = word + "(?:\\." + word + ")*"; - final String email = localPart + "@" + domain; - final String regex = "(\\s*" + email + "\\s*)*"; + @NonNls final String atom = "[^()<>@,;:\\\\\".\\[\\] \\x28\\p{Cntrl}]+"; + @NonNls final String word = "(?:" + atom + "|" + quotedString + ")"; + @NonNls final String subdomain = "(?:" + atom + "|\\[(?:[^\\[\\]\\\\]|\\\\\\p{ASCII})*\\])"; + @NonNls final String domain = subdomain + "(?:\\." + subdomain + ")*"; + @NonNls final String localPart = word + "(?:\\." + word + ")*"; + @NonNls final String email = localPart + "@" + domain; + @NonNls final String regex = "(\\s*" + email + "\\s*)*"; if (!emailAddress.matches(regex)) { return "Invalid email address"; } diff --git a/game-app/domain-data/src/main/java/org/triplea/domain/data/SystemIdLoader.java b/game-app/domain-data/src/main/java/org/triplea/domain/data/SystemIdLoader.java index 4a7567484da..70e92cc5892 100644 --- a/game-app/domain-data/src/main/java/org/triplea/domain/data/SystemIdLoader.java +++ b/game-app/domain-data/src/main/java/org/triplea/domain/data/SystemIdLoader.java @@ -10,12 +10,13 @@ import lombok.Setter; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; /** Loads a SystemId from persistence. */ @UtilityClass @Slf4j public class SystemIdLoader { - private static final String SYSTEM_KEY = "system-id-key"; + @NonNls private static final String SYSTEM_KEY = "system-id-key"; @Setter(value = AccessLevel.PACKAGE, onMethod_ = @VisibleForTesting) private static PreferencesPersistence preferencesPersistence = diff --git a/game-app/game-core/src/main/java/games/strategy/engine/ClientFileSystemHelper.java b/game-app/game-core/src/main/java/games/strategy/engine/ClientFileSystemHelper.java index daef2bab5a2..0e822bdf117 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/ClientFileSystemHelper.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/ClientFileSystemHelper.java @@ -12,6 +12,7 @@ import java.util.function.Supplier; import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.game.ApplicationContext; import org.triplea.io.FileUtils; import org.triplea.util.Services; @@ -19,7 +20,7 @@ /** Provides methods to work with common file locations in a client installation. */ @Slf4j public final class ClientFileSystemHelper { - public static final String USER_ROOT_FOLDER_NAME = "triplea"; + @NonNls public static final String USER_ROOT_FOLDER_NAME = "triplea"; @VisibleForTesting static final String MAPS_FOLDER_NAME = "downloadedMaps"; private static Path codeSourceLocation; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatController.java b/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatController.java index fd6f8d971c8..f5dfcfedb05 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatController.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatController.java @@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.domain.data.ChatParticipant; import org.triplea.domain.data.PlayerChatId; import org.triplea.domain.data.UserName; @@ -22,8 +23,8 @@ /** Default implementation of {@link IChatController}. */ @Slf4j public class ChatController implements IChatController { - private static final String CHAT_REMOTE = "_ChatRemote_"; - private static final String CHAT_CHANNEL = "_ChatControl_"; + @NonNls private static final String CHAT_REMOTE = "_ChatRemote_"; + @NonNls private static final String CHAT_CHANNEL = "_ChatControl_"; private final Messengers messengers; private final ServerMessenger serverMessenger; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatPlayerPanel.java b/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatPlayerPanel.java index d6f0e2e184a..0f476b187e4 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatPlayerPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/chat/ChatPlayerPanel.java @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.function.BiConsumer; import javax.swing.Action; import javax.swing.DefaultListCellRenderer; @@ -28,6 +29,7 @@ import javax.swing.JScrollPane; import javax.swing.ListCellRenderer; import javax.swing.UIManager; +import org.jetbrains.annotations.NonNls; import org.triplea.domain.data.ChatParticipant; import org.triplea.domain.data.UserName; import org.triplea.java.StringUtils; @@ -36,7 +38,7 @@ /** A UI component that displays the players participating in a chat. */ public class ChatPlayerPanel extends JPanel implements ChatPlayerListener { - private static final String TAG_MODERATOR = "[Mod]"; + @NonNls private static final String TAG_MODERATOR = "[Mod]"; private static final long serialVersionUID = -3153022965393962945L; private static final Icon ignoreIcon; @@ -270,7 +272,8 @@ public synchronized void updatePlayerList(final Collection upda updatedPlayers.stream() .sorted( Comparator.comparing( - chatParticipant -> chatParticipant.getUserName().getValue().toUpperCase())) + chatParticipant -> + chatParticipant.getUserName().getValue().toUpperCase(Locale.ENGLISH))) .forEach(listModel::addElement); }); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java b/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java index 6c3aa738548..1e4e92ab4cc 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java @@ -38,6 +38,7 @@ import java.util.function.Predicate; import lombok.Getter; import lombok.Setter; +import org.jetbrains.annotations.NonNls; import org.triplea.io.FileUtils; import org.triplea.io.IoUtils; import org.triplea.java.ObjectUtils; @@ -73,7 +74,7 @@ public class GameData implements Serializable, GameState { private static final long serialVersionUID = -2612710634080125728L; /** When we load a game from a save file, this property will be the name of that file. */ - private static final String SAVE_GAME_FILE_NAME_PROPERTY = "save.game.file.name"; + @NonNls private static final String SAVE_GAME_FILE_NAME_PROPERTY = "save.game.file.name"; private transient ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); private transient volatile boolean forceInSwingEventThread = false; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/GamePlayer.java b/game-app/game-core/src/main/java/games/strategy/engine/data/GamePlayer.java index d5d3f0cb82b..f77099841ee 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/GamePlayer.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/GamePlayer.java @@ -18,14 +18,15 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; +import org.jetbrains.annotations.NonNls; import org.triplea.java.RemoveOnNextMajorRelease; /** A game player (nation, power, etc.). */ public class GamePlayer extends NamedAttachable implements NamedUnitHolder { private static final long serialVersionUID = -2284878450555315947L; - private static final String DEFAULT_TYPE_AI = "AI"; - private static final String DEFAULT_TYPE_DOES_NOTHING = "DoesNothing"; + @NonNls private static final String DEFAULT_TYPE_AI = "AI"; + @NonNls private static final String DEFAULT_TYPE_DOES_NOTHING = "DoesNothing"; @RemoveOnNextMajorRelease @Deprecated private static final GamePlayer NULL_PLAYERID = @@ -127,12 +128,12 @@ public String getType() { } /** - * First string is "Human" or "AI" or "null" (case insensitive), while second string is the name + * First string is "Human" or "AI" or "null" (case-insensitive), while second string is the name * of the player, separated with a colon. For example, it could be "AI:Hard (AI)". * * @throws IllegalArgumentException If {@code encodedType} does not contain two strings separated - * by a colon; or if the first string is not one of "AI", "Human", or "null" (case - * insensitive). + * by a colon; or if the first string is not one of "AI", "Human", or "null" + * (case-insensitive). */ public void setWhoAmI(final String encodedType) { final List tokens = tokenizeEncodedType(encodedType); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/Unit.java b/game-app/game-core/src/main/java/games/strategy/engine/data/Unit.java index 29b92c27fbe..039f319f617 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/Unit.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/Unit.java @@ -4,6 +4,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; +import games.strategy.triplea.Constants; import games.strategy.triplea.Properties; import games.strategy.triplea.attachments.TerritoryAttachment; import games.strategy.triplea.attachments.UnitAttachment; @@ -19,6 +20,7 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.CollectionUtils; /** @@ -31,24 +33,24 @@ @Getter @EqualsAndHashCode(of = "id", callSuper = false) public class Unit extends GameDataComponent implements DynamicallyModifiable { - public static final String TRANSPORTED_BY = "transportedBy"; - public static final String UNLOADED = "unloaded"; - public static final String LOADED_THIS_TURN = "wasLoadedThisTurn"; - public static final String UNLOADED_TO = "unloadedTo"; - public static final String UNLOADED_IN_COMBAT_PHASE = "wasUnloadedInCombatPhase"; - public static final String ALREADY_MOVED = "alreadyMoved"; - public static final String BONUS_MOVEMENT = "bonusMovement"; - public static final String SUBMERGED = "submerged"; - public static final String WAS_IN_COMBAT = "wasInCombat"; - public static final String LOADED_AFTER_COMBAT = "wasLoadedAfterCombat"; - public static final String UNLOADED_AMPHIBIOUS = "wasAmphibious"; - public static final String ORIGINATED_FROM = "originatedFrom"; - public static final String WAS_SCRAMBLED = "wasScrambled"; - public static final String MAX_SCRAMBLE_COUNT = "maxScrambleCount"; - public static final String WAS_IN_AIR_BATTLE = "wasInAirBattle"; - public static final String LAUNCHED = "launched"; - public static final String AIRBORNE = "airborne"; - public static final String CHARGED_FLAT_FUEL_COST = "chargedFlatFuelCost"; + @NonNls public static final String TRANSPORTED_BY = "transportedBy"; + @NonNls public static final String UNLOADED = "unloaded"; + @NonNls public static final String LOADED_THIS_TURN = "wasLoadedThisTurn"; + @NonNls public static final String UNLOADED_TO = "unloadedTo"; + @NonNls public static final String UNLOADED_IN_COMBAT_PHASE = "wasUnloadedInCombatPhase"; + @NonNls public static final String ALREADY_MOVED = "alreadyMoved"; + @NonNls public static final String BONUS_MOVEMENT = "bonusMovement"; + @NonNls public static final String SUBMERGED = "submerged"; + @NonNls public static final String WAS_IN_COMBAT = "wasInCombat"; + @NonNls public static final String LOADED_AFTER_COMBAT = "wasLoadedAfterCombat"; + @NonNls public static final String UNLOADED_AMPHIBIOUS = "wasAmphibious"; + @NonNls public static final String ORIGINATED_FROM = "originatedFrom"; + @NonNls public static final String WAS_SCRAMBLED = "wasScrambled"; + @NonNls public static final String MAX_SCRAMBLE_COUNT = "maxScrambleCount"; + @NonNls public static final String WAS_IN_AIR_BATTLE = "wasInAirBattle"; + @NonNls public static final String LAUNCHED = "launched"; + @NonNls public static final String AIRBORNE = "airborne"; + @NonNls public static final String CHARGED_FLAT_FUEL_COST = "chargedFlatFuelCost"; private static final long serialVersionUID = -79061939642779999L; @@ -222,7 +224,7 @@ private static void printError(final String errorMessage) { } @Override - public @Nullable MutableProperty getPropertyOrNull(String propertyName) { + public @Nullable MutableProperty getPropertyOrNull(@NonNls String propertyName) { switch (propertyName) { case "owner": return MutableProperty.ofSimple(this::setOwner, this::getOwner); @@ -232,49 +234,49 @@ private static void printError(final String errorMessage) { return MutableProperty.ofSimple(this::setHits, this::getHits); case "type": return MutableProperty.ofReadOnlySimple(this::getType); - case "transportedBy": + case TRANSPORTED_BY: return MutableProperty.ofSimple(this::setTransportedBy, this::getTransportedBy); - case "unloaded": + case UNLOADED: return MutableProperty.ofSimple(this::setUnloaded, this::getUnloaded); - case "wasLoadedThisTurn": + case LOADED_THIS_TURN: return MutableProperty.ofSimple(this::setWasLoadedThisTurn, this::getWasLoadedThisTurn); - case "unloadedTo": + case UNLOADED_TO: return MutableProperty.ofSimple(this::setUnloadedTo, this::getUnloadedTo); - case "wasUnloadedInCombatPhase": + case UNLOADED_IN_COMBAT_PHASE: return MutableProperty.ofSimple( this::setWasUnloadedInCombatPhase, this::getWasUnloadedInCombatPhase); - case "alreadyMoved": + case ALREADY_MOVED: return MutableProperty.ofSimple(this::setAlreadyMoved, this::getAlreadyMoved); - case "bonusMovement": + case BONUS_MOVEMENT: return MutableProperty.ofSimple(this::setBonusMovement, this::getBonusMovement); case "unitDamage": return MutableProperty.ofSimple(this::setUnitDamage, this::getUnitDamage); - case "submerged": + case SUBMERGED: return MutableProperty.ofSimple(this::setSubmerged, this::getSubmerged); - case "originalOwner": + case Constants.ORIGINAL_OWNER: return MutableProperty.ofSimple(this::setOriginalOwner, this::getOriginalOwner); - case "wasInCombat": + case WAS_IN_COMBAT: return MutableProperty.ofSimple(this::setWasInCombat, this::getWasInCombat); - case "wasLoadedAfterCombat": + case LOADED_AFTER_COMBAT: return MutableProperty.ofSimple( this::setWasLoadedAfterCombat, this::getWasLoadedAfterCombat); - case "wasAmphibious": + case UNLOADED_AMPHIBIOUS: return MutableProperty.ofSimple(this::setWasAmphibious, this::getWasAmphibious); - case "originatedFrom": + case ORIGINATED_FROM: return MutableProperty.ofSimple(this::setOriginatedFrom, this::getOriginatedFrom); - case "wasScrambled": + case WAS_SCRAMBLED: return MutableProperty.ofSimple(this::setWasScrambled, this::getWasScrambled); - case "maxScrambleCount": + case MAX_SCRAMBLE_COUNT: return MutableProperty.ofSimple(this::setMaxScrambleCount, this::getMaxScrambleCount); - case "wasInAirBattle": + case WAS_IN_AIR_BATTLE: return MutableProperty.ofSimple(this::setWasInAirBattle, this::getWasInAirBattle); case "disabled": return MutableProperty.ofSimple(this::setDisabled, this::getDisabled); - case "launched": + case LAUNCHED: return MutableProperty.ofSimple(this::setLaunched, this::getLaunched); - case "airborne": + case AIRBORNE: return MutableProperty.ofSimple(this::setAirborne, this::getAirborne); - case "chargedFlatFuelCost": + case CHARGED_FLAT_FUEL_COST: return MutableProperty.ofSimple(this::setChargedFlatFuelCost, this::getChargedFlatFuelCost); default: return null; @@ -377,11 +379,11 @@ public void setTransportedBy(final Unit transportedBy) { } /** - * This is a very slow method because it checks all territories on the map. Try not to use this - * method if possible. + * Try not to use this method if possible. * * @return Unmodifiable collection of units that this unit is transporting in the same territory * it is located in + * @deprecated This is a very slow method because it checks all territories on the map. */ @Deprecated public List getTransporting() { @@ -488,11 +490,11 @@ public boolean canTakeHitWithoutBeingKilled() { } /** - * Avoid calling this method, it checks every territory on the map. To undeprecate we should + * Avoid calling this method, it checks every territory on the map. To avoid deprecation we should * optimize this to halt on the first territory we have found with a transporting unit, or * otherwise optimize this to not check every territory. * - * @deprecated Avoid callling this method, it calls {@link #getTransporting()} which is slow and + * @deprecated Avoid calling this method, it calls {@link #getTransporting()} which is slow and * needs optimization. */ @Deprecated diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/battle/phase/BattlePhaseList.java b/game-app/game-core/src/main/java/games/strategy/engine/data/battle/phase/BattlePhaseList.java index 041f4327a44..01ae860c3a3 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/battle/phase/BattlePhaseList.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/battle/phase/BattlePhaseList.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.Optional; import lombok.Getter; +import org.jetbrains.annotations.NonNls; /** * Stores all of the {@link BattlePhase}s that will be used during a battle @@ -17,10 +18,10 @@ @Getter public class BattlePhaseList { - public static final String DEFAULT_AA_PHASE = "AA"; - public static final String DEFAULT_BOMBARD_PHASE = "Bombard"; - public static final String DEFAULT_FIRST_STRIKE_PHASE = "First Strike"; - public static final String DEFAULT_GENERAL_PHASE = "General"; + @NonNls public static final String DEFAULT_AA_PHASE = "AA"; + @NonNls public static final String DEFAULT_BOMBARD_PHASE = "Bombard"; + @NonNls public static final String DEFAULT_FIRST_STRIKE_PHASE = "First Strike"; + @NonNls public static final String DEFAULT_GENERAL_PHASE = "General"; private final Collection phases = new ArrayList<>(); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java b/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java index b7337ae246f..b8639aff168 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/GameParser.java @@ -41,6 +41,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; @@ -49,6 +50,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.config.product.ProductVersionReader; import org.triplea.generic.xml.reader.XmlMapper; import org.triplea.generic.xml.reader.exceptions.XmlParsingException; @@ -75,7 +77,7 @@ /** Parses a game XML file into a {@link GameData} domain object. */ @Slf4j public final class GameParser { - private static final String RESOURCE_IS_DISPLAY_FOR_NONE = "NONE"; + @NonNls private static final String RESOURCE_IS_DISPLAY_FOR_NONE = "NONE"; @Nonnull private final GameData data; private final Path xmlUri; @@ -101,7 +103,7 @@ private GameParser( * * @param xmlFile The game XML file to be parsed. * @return A complete {@link GameData} instance that can be used to play the game, otherwise - * returns empty if the file could not parsed or is not valid. + * returns empty if the file could not be parsed or is not valid. */ public static Optional parse( final Path xmlFile, boolean collectAttachmentOrderAndValues) { @@ -115,15 +117,15 @@ public static Optional parse( // if parsed, find the 'map.yml' from a parent folder and set the 'mapName' property // using the 'map name' from 'map.yml' - if (gameData.isPresent()) { - FileUtils.findFileInParentFolders(xmlFile, MapDescriptionYaml.MAP_YAML_FILE_NAME) - .flatMap(MapDescriptionYaml::fromFile) - .ifPresent( - mapDescriptionYaml -> { - gameData.get().setGameName(mapDescriptionYaml.findGameNameFromXmlFileName(xmlFile)); - gameData.get().setMapName(mapDescriptionYaml.getMapName()); - }); - } + gameData.ifPresent( + data -> + FileUtils.findFileInParentFolders(xmlFile, MapDescriptionYaml.MAP_YAML_FILE_NAME) + .flatMap(MapDescriptionYaml::fromFile) + .ifPresent( + mapDescriptionYaml -> { + data.setGameName(mapDescriptionYaml.findGameNameFromXmlFileName(xmlFile)); + data.setMapName(mapDescriptionYaml.getMapName()); + })); return gameData; } @@ -274,13 +276,13 @@ private TerritoryEffect getTerritoryEffect(final String name) throws GameParseEx .orElseThrow(() -> new GameParseException("Could not find territoryEffect:" + name)); } - /** If cannot find the productionRule an exception will be thrown. */ + /** If the productionRule cannot be found an exception will be thrown. */ private ProductionRule getProductionRule(final String name) throws GameParseException { return Optional.ofNullable(data.getProductionRuleList().getProductionRule(name)) .orElseThrow(() -> new GameParseException("Could not find production rule:" + name)); } - /** If cannot find the repairRule an exception will be thrown. */ + /** If the repairRule cannot be found an exception will be thrown. */ private RepairRule getRepairRule(final String name) throws GameParseException { return Optional.ofNullable(data.getRepairRules().getRepairRule(name)) .orElseThrow(() -> new GameParseException("Could not find repair rule:" + name)); @@ -308,7 +310,7 @@ private TechAdvance getTechnology(final String name) throws GameParseException { .orElseThrow(() -> new GameParseException("Could not find technology:" + name)); } - /** If cannot find the Delegate an exception will be thrown. */ + /** If the Delegate cannot be found an exception will be thrown. */ private IDelegate getDelegate(final String name) throws GameParseException { return Optional.ofNullable(data.getDelegate(name)) .orElseThrow(() -> new GameParseException("Could not find delegate:" + name)); @@ -324,13 +326,13 @@ private Optional getResourceOptional(final String name) { return Optional.ofNullable(data.getResourceList().getResource(name)); } - /** If cannot find the productionRule an exception will be thrown. */ + /** If the productionFrontier cannot be found an exception will be thrown. */ private ProductionFrontier getProductionFrontier(final String name) throws GameParseException { return Optional.ofNullable(data.getProductionFrontierList().getProductionFrontier(name)) .orElseThrow(() -> new GameParseException("Could not find production frontier:" + name)); } - /** If cannot find the repairFrontier an exception will be thrown. */ + /** If the repairFrontier cannot be found an exception will be thrown. */ private RepairFrontier getRepairFrontier(final String name) throws GameParseException { return Optional.ofNullable(data.getRepairFrontierList().getRepairFrontier(name)) .orElseThrow(() -> new GameParseException("Could not find repair frontier:" + name)); @@ -900,6 +902,7 @@ private List> setOptions( continue; } final String count = option.getCount(); + @NonNls final String countAndValue = Strings.isNullOrEmpty(count) ? value : (count + ":" + value); if (containsEmptyForeachVariable(countAndValue, foreach)) { continue; // Skip adding option if contains empty foreach variable @@ -943,7 +946,7 @@ private boolean containsEmptyForeachVariable(final String s, final Map 0) ? value.substring(0, 1).toLowerCase() : "") + return ((!value.isEmpty()) ? value.substring(0, 1).toLowerCase(Locale.ROOT) : "") + ((value.length() > 1) ? value.substring(1) : ""); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java b/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java index 0fd3089de63..9f1e35fea1f 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/gameparser/LegacyPropertyMapper.java @@ -2,6 +2,7 @@ import games.strategy.triplea.Constants; import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NonNls; /** * This converts property names and values that were used in older map XMLs and updates those values @@ -27,7 +28,9 @@ static String mapLegacyOptionName(final String optionName) { return optionName; } - public String mapLegacyOptionValue(final String optionName, final String optionValue) { + @NonNls + public String mapLegacyOptionValue( + @NonNls final String optionName, @NonNls final String optionValue) { if (optionName.equalsIgnoreCase("victoryCity")) { if (optionValue.equalsIgnoreCase("true")) { return "1"; @@ -43,7 +46,7 @@ public String mapLegacyOptionValue(final String optionName, final String optionV return optionValue; } - public String mapPropertyName(final String propertyName) { + public String mapPropertyName(@NonNls final String propertyName) { if (propertyName.equalsIgnoreCase("Battleships repair at end of round") || propertyName.equalsIgnoreCase("Units repair at end of round")) { return Constants.TWO_HIT_BATTLESHIPS_REPAIR_END_OF_TURN; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/properties/MapProperty.java b/game-app/game-core/src/main/java/games/strategy/engine/data/properties/MapProperty.java index e7c0541d058..66ed53d44bb 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/properties/MapProperty.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/properties/MapProperty.java @@ -11,6 +11,8 @@ import java.util.Objects; import javax.swing.JComponent; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NonNls; /** * Basically creates a map of other properties. @@ -24,7 +26,8 @@ public class MapProperty extends AbstractEditableProperty> { private Map map; private final List> properties = new ArrayList<>(); - public MapProperty(final String name, final String description, final Map map) { + public MapProperty( + @NonNls final String name, @Nls final String description, final Map map) { super(name, description); checkNotNull(map); @@ -36,7 +39,7 @@ public MapProperty(final String name, final String description, final Map map, final List> properties, - final String description) { + @Nls final String description) { properties.clear(); map.forEach( (key, value) -> { diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java b/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java index d0267c587a1..9f2d14c894f 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java @@ -25,6 +25,7 @@ import lombok.RequiredArgsConstructor; import lombok.experimental.FieldDefaults; import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NonNls; /** * Auto-generates unit abilities from deprecated unit options @@ -34,7 +35,7 @@ @UtilityClass public class UnitAbilityFactory { - private static final String WILL_NOT_FIRE_AA_ABILITY_PREFIX = "willNotFireAa"; + @NonNls private static final String WILL_NOT_FIRE_AA_ABILITY_PREFIX = "willNotFireAa"; @RequiredArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/AbstractGame.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/AbstractGame.java index 9fb168b08bd..15c354b37df 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/AbstractGame.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/AbstractGame.java @@ -19,16 +19,21 @@ import java.util.Objects; import java.util.Set; import javax.annotation.Nullable; +import org.jetbrains.annotations.NonNls; import org.triplea.sound.ISound; /** * This abstract class keeps common variables and methods from a game (ClientGame or ServerGame). */ public abstract class AbstractGame implements IGame { + @NonNls private static final String DISPLAY_CHANNEL = "games.strategy.engine.framework.AbstractGame.DISPLAY_CHANNEL"; + + @NonNls private static final String SOUND_CHANNEL = "games.strategy.engine.framework.AbstractGame.SOUND_CHANNEL"; + protected final GameData gameData; protected final Messengers messengers; protected volatile boolean isGameOver = false; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java index 3332309fed2..40ce83caf80 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java @@ -1,18 +1,20 @@ package games.strategy.engine.framework; +import org.jetbrains.annotations.NonNls; + /** A collection of all CLI related constants. */ public class CliProperties { - public static final String TRIPLEA_GAME = "triplea.game"; - public static final String TRIPLEA_SERVER = "triplea.server"; - public static final String TRIPLEA_CLIENT = "triplea.client"; - public static final String TRIPLEA_HOST = "triplea.host"; - public static final String TRIPLEA_PORT = "triplea.port"; - public static final String TRIPLEA_NAME = "triplea.name"; - public static final String SERVER_PASSWORD = "triplea.server.password"; - public static final String LOBBY_URI = "triplea.lobby.uri"; - public static final String LOBBY_GAME_COMMENTS = "triplea.lobby.game.comments"; - public static final String MAP_FOLDER = "triplea.map.folder"; - public static final String TRIPLEA_MAP_DOWNLOAD = "triplea.map.download"; + @NonNls public static final String TRIPLEA_GAME = "triplea.game"; + @NonNls public static final String TRIPLEA_SERVER = "triplea.server"; + @NonNls public static final String TRIPLEA_CLIENT = "triplea.client"; + @NonNls public static final String TRIPLEA_HOST = "triplea.host"; + @NonNls public static final String TRIPLEA_PORT = "triplea.port"; + @NonNls public static final String TRIPLEA_NAME = "triplea.name"; + @NonNls public static final String SERVER_PASSWORD = "triplea.server.password"; + @NonNls public static final String LOBBY_URI = "triplea.lobby.uri"; + @NonNls public static final String LOBBY_GAME_COMMENTS = "triplea.lobby.game.comments"; + @NonNls public static final String MAP_FOLDER = "triplea.map.folder"; + @NonNls public static final String TRIPLEA_MAP_DOWNLOAD = "triplea.map.download"; private CliProperties() {} } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataFileUtils.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataFileUtils.java index 2476340c4e7..0f70c4d53da 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataFileUtils.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataFileUtils.java @@ -6,6 +6,7 @@ import java.util.Collection; import java.util.List; import org.apache.commons.io.IOCase; +import org.jetbrains.annotations.NonNls; /** A collection of utilities for working with game data files. */ public final class GameDataFileUtils { @@ -31,11 +32,11 @@ static String addExtensionIfAbsent(final String fileName, final IOCase ioCase) { } private static Collection getCandidateExtensions() { - final String legacyExtension = ".svg"; + @NonNls final String legacyExtension = ".svg"; // Macs download a game data file as "tsvg.gz", so that extension must be used when evaluating // candidate game data files. - final String macOsAlternativeExtension = "tsvg.gz"; + @NonNls final String macOsAlternativeExtension = "tsvg.gz"; return List.of(getExtension(), legacyExtension, macOsAlternativeExtension); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java index 7eb257c1f25..c43f5451948 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java @@ -21,14 +21,15 @@ import lombok.Builder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; +import org.jetbrains.annotations.NonNls; import org.triplea.config.product.ProductVersionReader; /** Responsible for loading saved games, new games from xml, and saving games. */ @Slf4j public final class GameDataManager { - private static final String DELEGATE_START = ""; - private static final String DELEGATE_DATA_NEXT = ""; - private static final String DELEGATE_LIST_END = ""; + @NonNls private static final String DELEGATE_START = ""; + @NonNls private static final String DELEGATE_DATA_NEXT = ""; + @NonNls private static final String DELEGATE_LIST_END = ""; private GameDataManager() {} diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameRunner.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameRunner.java index d5f648782a9..e1facc89055 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameRunner.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameRunner.java @@ -1,10 +1,12 @@ package games.strategy.engine.framework; +import org.jetbrains.annotations.NonNls; + /** In this class commonly used constants are getting defined. */ public final class GameRunner { - public static final String TRIPLEA_HEADLESS = "triplea.headless"; - public static final String BOT_GAME_HOST_COMMENT = "automated_host"; - public static final String BOT_GAME_HOST_NAME_PREFIX = "Bot"; + @NonNls public static final String TRIPLEA_HEADLESS = "triplea.headless"; + @NonNls public static final String BOT_GAME_HOST_COMMENT = "automated_host"; + @NonNls public static final String BOT_GAME_HOST_NAME_PREFIX = "Bot"; public static final int PORT = 3300; public static boolean headless() { diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nEngineFramework.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nEngineFramework.java index 44e5058b741..d7defe22335 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nEngineFramework.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nEngineFramework.java @@ -1,5 +1,7 @@ package games.strategy.engine.framework; +import org.jetbrains.annotations.NonNls; + public class I18nEngineFramework extends I18nResourceBundle { private static I18nResourceBundle instance; @@ -11,7 +13,7 @@ public static I18nResourceBundle get() { } @Override - public String getResourcePath() { + public @NonNls String getResourcePath() { return "i18n.games.strategy.engine.framework.ui"; } } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nResourceBundle.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nResourceBundle.java index 1cfada5ace3..deba0831c62 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nResourceBundle.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/I18nResourceBundle.java @@ -51,7 +51,7 @@ public static List getSupportedLanguageRange() { } /* - * @param number Number to be language-dependent converted to string + * @param long number to be language-dependently converted to string * @return Language-dependent string for number */ /*public static String convToText(final long number) { @@ -59,14 +59,14 @@ public static List getSupportedLanguageRange() { }*/ /* - * @param date Date to be language-dependent converted to string + * @param date to be language-dependently converted to string * @return Language-dependent string for date */ /*public static String convToText(final Date date) { return convToText(date, DateFormat.SHORT); }*/ /* - * @param date Date to be language-dependent converted to string + * @param date to be language-dependently converted to string * @param style Date formatting style to be used * @return Language-dependent string for date */ diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/ServerGame.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/ServerGame.java index 99dbb62d336..4ea95bb3430 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/ServerGame.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/ServerGame.java @@ -56,6 +56,7 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.Interruptibles; import org.triplea.java.ThreadRunner; import org.triplea.util.ExitStatus; @@ -63,8 +64,10 @@ /** Implementation of {@link IGame} for a network server node. */ @Slf4j public class ServerGame extends AbstractGame { + @NonNls public static final String GAME_HAS_BEEN_SAVED_PROPERTY = "games.strategy.engine.framework.ServerGame.GameHasBeenSaved"; + static final RemoteName SERVER_REMOTE = new RemoteName( "games.strategy.engine.framework.ServerGame.SERVER_REMOTE", IServerRemote.class); @@ -670,7 +673,7 @@ private void addPlayerTypesToGameData( final GamePlayer p = data.getPlayerList().getPlayerId(player.getName()); final boolean isAi = player.isAi(); - final String newWhoAmI = (isAi ? "AI" : "Human") + ":" + player.getPlayerLabel(); + @NonNls final String newWhoAmI = (isAi ? "AI" : "Human") + ":" + player.getPlayerLabel(); if (!p.getWhoAmI().equals(newWhoAmI)) { change.add(ChangeFactory.changePlayerWhoAmIChange(p, newWhoAmI)); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadFile.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadFile.java index 666a89af761..866b71bbe71 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadFile.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadFile.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Path; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.http.client.maps.listing.MapDownloadItem; import org.triplea.io.FileUtils; import org.triplea.java.ThreadRunner; @@ -50,7 +51,7 @@ void startAsyncDownload() { return; } - final String fileNameToWrite = normalizeMapName(download.getMapName()) + ".zip"; + @NonNls final String fileNameToWrite = normalizeMapName(download.getMapName()) + ".zip"; final Path targetTempFileToDownloadTo = FileUtils.newTempFolder().resolve(fileNameToWrite); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindow.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindow.java index 9f55baa7e1c..55e0e0db8e2 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindow.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindow.java @@ -19,6 +19,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.function.Consumer; @@ -222,7 +223,7 @@ private static Optional findMap( } private static String normalizeName(final String mapName) { - return mapName.replace(' ', '_').toLowerCase(); + return mapName.replace(' ', '_').toLowerCase(Locale.ROOT); } private JTabbedPane newAvailableInstalledTabbedPanel( @@ -248,7 +249,7 @@ private JTabbedPane newAvailableInstalledTabbedPanel( final JPanel installed = newMapSelectionPanel( mapList.getInstalled().keySet().stream() - .sorted(Comparator.comparing(m -> m.getMapName().toUpperCase())) + .sorted(Comparator.comparing(m -> m.getMapName().toUpperCase(Locale.ENGLISH))) .collect(Collectors.toList()), MapAction.REMOVE, false); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindowModel.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindowModel.java index 3398cba11bd..fd096e86735 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindowModel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/download/DownloadMapsWindowModel.java @@ -6,6 +6,7 @@ import java.nio.file.Path; import java.util.Optional; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.http.client.maps.listing.MapDownloadItem; import org.triplea.io.FileUtils; import org.triplea.java.Interruptibles; @@ -58,7 +59,7 @@ boolean delete(final MapDownloadItem mapDownloadItem) { } String toHtmlString(final MapDownloadItem mapDownloadItem) { - String text = "

" + mapDownloadItem.getMapName() + "

\n"; + @NonNls String text = "

" + mapDownloadItem.getMapName() + "

\n"; if (!mapDownloadItem.getPreviewImageUrl().isEmpty()) { text += "\n"; } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/InstalledMapsListing.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/InstalledMapsListing.java index 5ae18305012..d74177c7604 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/InstalledMapsListing.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/InstalledMapsListing.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @@ -115,7 +116,7 @@ public Optional findContentRootForMapName(final String mapName) { } private static String normalizeName(final String mapName) { - return mapName.toLowerCase().replaceAll("[_ -]", ""); + return mapName.toLowerCase(Locale.ROOT).replaceAll("[_ -]", ""); } /** diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/ZippedMapsExtractor.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/ZippedMapsExtractor.java index e53e8ecaf9d..81de6555567 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/ZippedMapsExtractor.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/map/file/system/loader/ZippedMapsExtractor.java @@ -9,12 +9,14 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.Collection; +import java.util.Locale; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; import lombok.Builder; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.io.FileUtils; import org.triplea.io.ZipExtractor; import org.triplea.io.ZipExtractor.FileSystemException; @@ -28,7 +30,7 @@ @Builder @Slf4j public class ZippedMapsExtractor { - private static final String ZIP_EXTENSION = ".zip"; + @NonNls private static final String ZIP_EXTENSION = ".zip"; /** * Callback to be invoked if we find any zip files. The task passed to the progress indicator will @@ -79,7 +81,7 @@ public void unzipMapFiles() { zipReadException)); } } catch (final FileSystemException e) { - // Thrown if we are are out of disk space or have file system access issues. + // Thrown if we are out of disk space or have file system access issues. // Do not move the zip file to a bad-zip folder as that operation could also // fail. log.warn("Error extracting map zip: {}, {}", mapZip, e.getMessage(), e); @@ -95,17 +97,18 @@ public void unzipMapFiles() { private Collection findAllZippedMapFiles() { return FileUtils.listFiles(downloadedMapsFolder).stream() .filter(Predicate.not(Files::isDirectory)) - .filter(file -> file.getFileName().toString().toLowerCase().endsWith(ZIP_EXTENSION)) + .filter( + file -> file.getFileName().toString().toLowerCase(Locale.ROOT).endsWith(ZIP_EXTENSION)) .collect(Collectors.toList()); } /** * Unzips are target map file into the downloaded maps folder, deletes the zip file after * extraction. Extracted files are first extracted to a temporary location before being moved into - * the downloaded maps folder. This temporary location is to help avoid intermediate results if + * the downloaded map's folder. This temporary location is to help avoid intermediate results if * for example we run out of disk space while extracting. * - * @param mapZip The map zip file to be extracted to the downloaded maps folder. + * @param mapZip The map zip file to be extracted to the downloaded map's folder. * @return Returns extracted location (if successful, otherwise empty) */ public static Optional unzipMap(final Path mapZip) { @@ -169,7 +172,7 @@ static String computeExtractionFolderName(final String mapZipName) { if (newName.endsWith("-master")) { newName = newName.substring(0, newName.length() - "-master".length()); } - return newName.toLowerCase(); + return newName.toLowerCase(Locale.ROOT); } /** diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/login/ClientLogin.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/login/ClientLogin.java index 7366fed4af9..6a50f780e31 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/login/ClientLogin.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/login/ClientLogin.java @@ -8,6 +8,7 @@ import javax.swing.JOptionPane; import javax.swing.JPasswordField; import lombok.AllArgsConstructor; +import org.jetbrains.annotations.NonNls; import org.triplea.java.Interruptibles; import org.triplea.swing.SwingAction; import org.triplea.util.Version; @@ -21,7 +22,7 @@ */ @AllArgsConstructor public class ClientLogin implements IConnectionLogin { - static final String ENGINE_VERSION_PROPERTY = "Engine.Version"; + @NonNls static final String ENGINE_VERSION_PROPERTY = "Engine.Version"; private final Component parentComponent; private final Version engineVersion; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java index f75bb7f67d0..99f6d0b0176 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java @@ -53,6 +53,7 @@ import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.game.chat.ChatModel; import org.triplea.http.client.lobby.game.hosting.request.GameHostingClient; import org.triplea.http.client.lobby.game.hosting.request.GameHostingResponse; @@ -72,6 +73,7 @@ public class ServerModel extends Observable implements IConnectionChangeListener "games.strategy.engine.framework.ui.ServerStartup.SERVER_REMOTE", IServerStartupRemote.class); + @NonNls static final String CHAT_NAME = "games.strategy.engine.framework.ui.ServerStartup.CHAT_NAME"; private final GameObjectStreamFactory objectStreamFactory = new GameObjectStreamFactory(null); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcher.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcher.java index 93f3b91f411..afc533708cd 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcher.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcher.java @@ -17,6 +17,7 @@ import javax.annotation.Nullable; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.http.client.lobby.game.lobby.watcher.GameListingClient; import org.triplea.http.client.lobby.game.lobby.watcher.GamePostingRequest; import org.triplea.http.client.lobby.game.lobby.watcher.GamePostingResponse; @@ -195,9 +196,10 @@ public static Optional newInGameLobbyWatcher( } } + @NonNls @VisibleForTesting static String getLobbySystemProperty(final String key) { - final String backupKey = key + ".backup"; + @NonNls final String backupKey = key + ".backup"; final @Nullable String value = System.getProperty(key); if (value != null) { System.setProperty(backupKey, value); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModel.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModel.java index b9462c15bfe..c6cd9f53d39 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModel.java @@ -18,6 +18,7 @@ import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.List; +import java.util.Locale; import java.util.Observable; import java.util.Optional; import java.util.concurrent.CountDownLatch; @@ -209,7 +210,7 @@ public void loadDefaultGameSameThread() { .ifPresentOrElse( (file) -> { // if the file name is xml, load it as a new game - if (file.getFileName().toString().toLowerCase().endsWith("xml")) { + if (file.getFileName().toString().toLowerCase(Locale.ROOT).endsWith("xml")) { loadMap(file); } else { // try to load it as a saved game whatever the extension diff --git a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java index 6e7b22c99a1..ff873c860b0 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java @@ -25,6 +25,7 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import org.jetbrains.annotations.NonNls; import org.triplea.awt.OpenFileUtility; import org.triplea.yaml.YamlReader; @@ -35,8 +36,10 @@ */ public class NodeBbForumPoster { + @NonNls public static final String AXIS_AND_ALLIES_ORG_DISPLAY_NAME = "www.axisandallies.org/forums/"; - public static final String TRIPLEA_FORUM_DISPLAY_NAME = "forums.triplea-game.org"; + + @NonNls public static final String TRIPLEA_FORUM_DISPLAY_NAME = "forums.triplea-game.org"; private final int topicId; private final String token; diff --git a/game-app/game-core/src/main/java/games/strategy/engine/random/MartiDiceRoller.java b/game-app/game-core/src/main/java/games/strategy/engine/random/MartiDiceRoller.java index 6e67458a6e4..d6e0d294381 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/random/MartiDiceRoller.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/random/MartiDiceRoller.java @@ -32,13 +32,14 @@ import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; +import org.jetbrains.annotations.NonNls; import org.triplea.config.product.ProductVersionReader; /** A pbem dice roller that reads its configuration from a properties file. */ @Builder public final class MartiDiceRoller implements IRemoteDiceServer { private static final int MESSAGE_MAX_LENGTH = 200; - private static final String DICE_ROLLER_PATH = "/MARTI.php"; + @NonNls private static final String DICE_ROLLER_PATH = "/MARTI.php"; private final Pattern errorPattern = Pattern.compile("fatal error:(.*)!"); @@ -72,8 +73,8 @@ public String getDisplayName() { public String postRequest( final int max, final int numDice, final String subjectMessage, final String gameId) throws IOException { - final String normalizedGameId = gameId.isBlank() ? "TripleA" : gameId; - String message = normalizedGameId + ":" + subjectMessage; + @NonNls final String normalizedGameId = gameId.isBlank() ? "TripleA" : gameId; + @NonNls String message = normalizedGameId + ":" + subjectMessage; if (message.length() > MESSAGE_MAX_LENGTH) { message = message.substring(0, MESSAGE_MAX_LENGTH - 1); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/vault/Vault.java b/game-app/game-core/src/main/java/games/strategy/engine/vault/Vault.java index b746599ade2..b25ef902074 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/vault/Vault.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/vault/Vault.java @@ -17,6 +17,7 @@ import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESKeySpec; +import org.jetbrains.annotations.NonNls; /** * A vault is a secure way for the client and server to share information without trusting each @@ -34,7 +35,7 @@ public class Vault { private static final RemoteName VAULT_CHANNEL = new RemoteName("games.strategy.engine.vault.IServerVault.VAULT_CHANNEL", IRemoteVault.class); - private static final String ALGORITHM = "DES"; + @NonNls private static final String ALGORITHM = "DES"; // 0xCAFEBABE // we encrypt both this value and data when we encrypt data. // when decrypting we ensure that KNOWN_VAL is correct and thus guarantee that we are being given @@ -241,7 +242,7 @@ public byte[] get(final VaultId id) throws NotUnlockedException { } } - /** Do we know about the given vault id. */ + /** {@code @TODO} Do we know about the given vault id? */ public boolean knowsAbout(final VaultId id) { return verifiedValues.containsKey(id) || unverifiedValues.containsKey(id); } diff --git a/game-app/game-core/src/main/java/games/strategy/net/nio/ForgotPasswordConversation.java b/game-app/game-core/src/main/java/games/strategy/net/nio/ForgotPasswordConversation.java index 340fa8d7653..f4d36ca4e0e 100644 --- a/game-app/game-core/src/main/java/games/strategy/net/nio/ForgotPasswordConversation.java +++ b/game-app/game-core/src/main/java/games/strategy/net/nio/ForgotPasswordConversation.java @@ -6,6 +6,7 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; import lombok.Builder; +import org.jetbrains.annotations.NonNls; /** * A subsequence of server conversation to handle requests for password reset. Returns a magic @@ -14,7 +15,7 @@ @Builder public class ForgotPasswordConversation { - public static final String TEMP_PASSWORD_GENERATED_RESPONSE = "password_reset"; + @NonNls public static final String TEMP_PASSWORD_GENERATED_RESPONSE = "password_reset"; @VisibleForTesting static final int MAX_TEMP_PASSWORD_REQUESTS_PER_DAY = 3; @Nonnull private final Predicate forgotPasswordModule; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java b/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java index 1178b3a94b1..4e41be732dc 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java @@ -1,8 +1,10 @@ package games.strategy.triplea; import games.strategy.engine.data.GamePlayer; +import org.jetbrains.annotations.NonNls; /** Constants used throughout the game. */ +@NonNls public interface Constants { // Player names String PLAYER_NAME_AMERICANS = "Americans"; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractConditionsAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractConditionsAttachment.java index 129df916b32..f33d1ebe522 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractConditionsAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractConditionsAttachment.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,6 +25,7 @@ import java.util.regex.Pattern; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; /** * This class is designed to hold common code for holding "conditions". Any attachment that can hold @@ -31,13 +33,13 @@ * collection fields default to null to minimize memory use and serialization size. */ public abstract class AbstractConditionsAttachment extends DefaultAttachment implements ICondition { - public static final String TRIGGER_CHANCE_SUCCESSFUL = "Trigger Rolling is a Success!"; - public static final String TRIGGER_CHANCE_FAILURE = "Trigger Rolling is a Failure!"; - protected static final String AND = "AND"; - protected static final String OR = "OR"; + public static final @NonNls String TRIGGER_CHANCE_SUCCESSFUL = "Trigger Rolling is a Success!"; + public static final @NonNls String TRIGGER_CHANCE_FAILURE = "Trigger Rolling is a Failure!"; + @NonNls protected static final String AND = "AND"; + @NonNls protected static final String OR = "OR"; private static final Pattern CONDITION_REGEX = Pattern.compile("AND|OR|\\d+(?:-\\d+)?"); - protected static final String DEFAULT_CHANCE = "1:1"; - protected static final String CHANCE = "chance"; + @NonNls protected static final String DEFAULT_CHANCE = "1:1"; + protected static final @NonNls String PROPERTY_CHANCE = "chance"; private static final long serialVersionUID = -9008441256118867078L; private static final Splitter HYPHEN_SPLITTER = Splitter.on('-'); @@ -108,7 +110,7 @@ private boolean getInvert() { @VisibleForTesting void setConditionType(final String value) throws GameParseException { - final String uppercaseValue = value.toUpperCase(); + final String uppercaseValue = value.toUpperCase(Locale.ENGLISH); if (CONDITION_REGEX.matcher(uppercaseValue).matches()) { final String[] split = splitOnHyphen(uppercaseValue); if (split.length != 2 || Integer.parseInt(split[1]) > Integer.parseInt(split[0])) { @@ -327,7 +329,7 @@ public void changeChanceDecrementOrIncrementOnSuccessOrFailure( if (newToHit == oldToHit) { return; } - final String newChance = newToHit + ":" + diceSides; + @NonNls final String newChance = newToHit + ":" + diceSides; delegateBridge .getHistoryWriter() .startEvent( @@ -335,7 +337,8 @@ public void changeChanceDecrementOrIncrementOnSuccessOrFailure( + MyFormatter.attachmentNameToText(getName()) + " to " + newChance); - delegateBridge.addChange(ChangeFactory.attachmentPropertyChange(this, newChance, CHANCE)); + delegateBridge.addChange( + ChangeFactory.attachmentPropertyChange(this, newChance, PROPERTY_CHANCE)); } else { if (chanceIncrementOnFailure == 0) { return; @@ -346,7 +349,7 @@ public void changeChanceDecrementOrIncrementOnSuccessOrFailure( if (newToHit == oldToHit) { return; } - final String newChance = newToHit + ":" + diceSides; + @NonNls final String newChance = newToHit + ":" + diceSides; if (historyChild) { delegateBridge .getHistoryWriter() @@ -364,12 +367,13 @@ public void changeChanceDecrementOrIncrementOnSuccessOrFailure( + " to " + newChance); } - delegateBridge.addChange(ChangeFactory.attachmentPropertyChange(this, newChance, CHANCE)); + delegateBridge.addChange( + ChangeFactory.attachmentPropertyChange(this, newChance, PROPERTY_CHANCE)); } } @Override - public @Nullable MutableProperty getPropertyOrNull(String propertyName) { + public @Nullable MutableProperty getPropertyOrNull(@NonNls String propertyName) { switch (propertyName) { case "conditions": return MutableProperty.of( @@ -380,7 +384,7 @@ public void changeChanceDecrementOrIncrementOnSuccessOrFailure( case "invert": return MutableProperty.ofMapper( DefaultAttachment::getBool, this::setInvert, this::getInvert, () -> false); - case "chance": + case PROPERTY_CHANCE: return MutableProperty.ofString(this::setChance, this::getChance, this::resetChance); case "chanceIncrementOnFailure": return MutableProperty.ofMapper( diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractTriggerAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractTriggerAttachment.java index a259d852857..5ab67addea4 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractTriggerAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractTriggerAttachment.java @@ -19,6 +19,7 @@ import java.util.function.Predicate; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; import org.triplea.java.Interruptibles; import org.triplea.java.RemoveOnNextMajorRelease; import org.triplea.util.Tuple; @@ -32,8 +33,8 @@ @RemoveOnNextMajorRelease public abstract class AbstractTriggerAttachment extends AbstractConditionsAttachment { public static final String NOTIFICATION = "Notification"; - public static final String AFTER = "after"; - public static final String BEFORE = "before"; + public static final @NonNls String AFTER = "after"; + public static final @NonNls String BEFORE = "before"; public static final Predicate availableUses = t -> t.getUses() != 0; private static final long serialVersionUID = 5866039180681962697L; @@ -180,7 +181,8 @@ protected boolean testChance(final IDelegateBridge bridge) { return false; } // there is an issue with maps using thousands of chance triggers: they are causing the cypted - // random source (ie: live and pbem games) to lock up or error out so we need to slow them down + // random source (i.e. live and pbem games) to lock up or error out, so we need to slow them + // down // a bit, until we come up with a better solution (like aggregating all the chances together, // then getting a ton of random numbers at once instead of one at a time) if (PbemMessagePoster.gameDataHasPlayByEmailOrForumMessengers(getData())) { @@ -228,7 +230,7 @@ public static Predicate isSatisfiedMatch( * args, otherwise false */ public static Predicate whenOrDefaultMatch( - final String beforeOrAfter, final String stepName) { + final @NonNls String beforeOrAfter, final @NonNls String stepName) { return t -> { if (beforeOrAfter == null && stepName == null && t.getWhen().isEmpty()) { return true; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractUserActionAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractUserActionAttachment.java index b7ddb43aa62..cba150751ad 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractUserActionAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/AbstractUserActionAttachment.java @@ -14,6 +14,7 @@ import java.util.Map; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.IntegerMap; /** @@ -22,7 +23,7 @@ * serialization size. */ public abstract class AbstractUserActionAttachment extends AbstractConditionsAttachment { - public static final String ATTEMPTS_LEFT_THIS_TURN = "attemptsLeftThisTurn"; + @NonNls public static final String ATTEMPTS_LEFT_THIS_TURN = "attemptsLeftThisTurn"; private static final long serialVersionUID = 3569461523853104614L; /** diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RelationshipTypeAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RelationshipTypeAttachment.java index 608b5a18593..d549925963c 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RelationshipTypeAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RelationshipTypeAttachment.java @@ -8,26 +8,28 @@ import games.strategy.engine.data.RelationshipType; import games.strategy.engine.data.gameparser.GameParseException; import games.strategy.triplea.Constants; +import java.util.Locale; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; /** An attachment for instances of {@link RelationshipType}. */ public class RelationshipTypeAttachment extends DefaultAttachment { - public static final String ARCHETYPE_NEUTRAL = Constants.RELATIONSHIP_ARCHETYPE_NEUTRAL; - public static final String ARCHETYPE_WAR = Constants.RELATIONSHIP_ARCHETYPE_WAR; - public static final String ARCHETYPE_ALLIED = Constants.RELATIONSHIP_ARCHETYPE_ALLIED; - public static final String UPKEEP_FLAT = "flat"; - public static final String UPKEEP_PERCENTAGE = "percentage"; - public static final String PROPERTY_DEFAULT = Constants.RELATIONSHIP_PROPERTY_DEFAULT; - public static final String PROPERTY_TRUE = Constants.RELATIONSHIP_PROPERTY_TRUE; - public static final String PROPERTY_FALSE = Constants.RELATIONSHIP_PROPERTY_FALSE; + @NonNls public static final String ARCHETYPE_NEUTRAL = Constants.RELATIONSHIP_ARCHETYPE_NEUTRAL; + @NonNls public static final String ARCHETYPE_WAR = Constants.RELATIONSHIP_ARCHETYPE_WAR; + @NonNls public static final String ARCHETYPE_ALLIED = Constants.RELATIONSHIP_ARCHETYPE_ALLIED; + @NonNls public static final String UPKEEP_FLAT = "flat"; + @NonNls public static final String UPKEEP_PERCENTAGE = "percentage"; + @NonNls public static final String PROPERTY_DEFAULT = Constants.RELATIONSHIP_PROPERTY_DEFAULT; + @NonNls public static final String PROPERTY_TRUE = Constants.RELATIONSHIP_PROPERTY_TRUE; + @NonNls public static final String PROPERTY_FALSE = Constants.RELATIONSHIP_PROPERTY_FALSE; private static final long serialVersionUID = -4367286684249791984L; /** * -- GETTER -- Returns the ArcheType of this relationshipType, this really shouldn't be called, * typically you should call isNeutral, isAllied or isWar(). */ - @Getter private String archeType = ARCHETYPE_WAR; + @Getter private @NonNls String archeType = ARCHETYPE_WAR; private String canMoveLandUnitsOverOwnedLand = PROPERTY_DEFAULT; private String canMoveAirUnitsOverOwnedLand = PROPERTY_DEFAULT; @@ -37,7 +39,7 @@ public class RelationshipTypeAttachment extends DefaultAttachment { private String canLandAirUnitsOnOwnedLand = PROPERTY_DEFAULT; private String canTakeOverOwnedTerritory = PROPERTY_DEFAULT; private String givesBackOriginalTerritories = PROPERTY_DEFAULT; - private String canMoveIntoDuringCombatMove = PROPERTY_DEFAULT; + private @NonNls String canMoveIntoDuringCombatMove = PROPERTY_DEFAULT; private String canMoveThroughCanals = PROPERTY_DEFAULT; private String rocketsCanFlyOver = PROPERTY_DEFAULT; @@ -67,14 +69,14 @@ static RelationshipTypeAttachment get(final RelationshipType pr, final String na * some option in this attachment; for example the RelationshipType ColdWar could be based on the * WAR_ARCHETYPE but overrides options like "canInvade" "canAttackHomeTerritory" to not allow * all-out invasion to mimic a not-all-out-war. Or you could base it on NEUTRAL_ARCHETYPE but - * override the options like "canAttackAtSea" and "canFireAA" to mimic a uneasy peace. + * override the options like "canAttackAtSea" and "canFireAA" to mimic an uneasy peace. * * @param archeType the template used to base this relationType on, can be war, allied or neutral, * default archeType = WAR_ARCHETYPE * @throws GameParseException if archeType isn't set to war, allied or neutral */ public void setArcheType(final String archeType) throws GameParseException { - final String lowerArcheType = archeType.toLowerCase(); + final String lowerArcheType = archeType.toLowerCase(Locale.ROOT); switch (lowerArcheType) { case ARCHETYPE_WAR: case ARCHETYPE_ALLIED: @@ -99,7 +101,7 @@ private void resetArcheType() { } /** - * EXAMPLE method on how you could do finegrained authorizations instead of + * EXAMPLE method on how you could do fine-grained authorizations instead of * looking at isNeutral, isAllied or isWar(); Just for future reference, doesn't do anything right * now. * @@ -114,7 +116,7 @@ private String getCanMoveAirUnitsOverOwnedLand() { } /** - * EXAMPLE method on how you could do finegrained authorizations instead of + * EXAMPLE method on how you could do fine-grained authorizations instead of * looking at isNeutral, isAllied or isWar(); Just for future reference, doesn't do anything right * now. * @@ -387,7 +389,7 @@ private void resetCanMoveThroughCanals() { canMoveThroughCanals = PROPERTY_DEFAULT; } - private void setRocketsCanFlyOver(final String value) throws GameParseException { + private void setRocketsCanFlyOver(final @NonNls String value) throws GameParseException { if (!(value.equals(PROPERTY_DEFAULT) || value.equals(PROPERTY_FALSE) || value.equals(PROPERTY_TRUE))) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RulesAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RulesAttachment.java index 8f07ce8da79..32c6d625a4a 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RulesAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/RulesAttachment.java @@ -38,6 +38,7 @@ import java.util.function.Predicate; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.VisibleForTesting; import org.triplea.java.Interruptibles; import org.triplea.java.collections.CollectionUtils; @@ -283,7 +284,7 @@ private void setRelationship(final String value) throws GameParseException { if (relationship == null) { relationship = new ArrayList<>(); } - String str = (s.length == 3) ? (value + ":-1") : value; + @NonNls String str = (s.length == 3) ? (value + ":-1") : value; relationship.add(str.intern()); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TechAbilityAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TechAbilityAttachment.java index 984069a2fb3..3482eca69f7 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TechAbilityAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TechAbilityAttachment.java @@ -26,6 +26,7 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import lombok.Getter; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; @@ -36,8 +37,8 @@ */ public class TechAbilityAttachment extends DefaultAttachment { // unitAbilitiesGained Static Strings - public static final String ABILITY_CAN_BLITZ = "canBlitz"; - public static final String ABILITY_CAN_BOMBARD = "canBombard"; + @NonNls public static final String ABILITY_CAN_BLITZ = "canBlitz"; + @NonNls public static final String ABILITY_CAN_BOMBARD = "canBombard"; private static final long serialVersionUID = 1866305599625384294L; @@ -80,7 +81,7 @@ public static TechAbilityAttachment get(final TechAdvance type) { if (type instanceof GenericTechAdvance) { // generic techs can name a hardcoded tech, therefore if it exists we should use the hard // coded tech's attachment. - // (if the map maker doesn't want to use the hardcoded tech's attachment, they should not name + // (if the mapmaker doesn't want to use the hardcoded tech's attachment, they should not name // a hardcoded tech) final TechAdvance hardCodedAdvance = ((GenericTechAdvance) type).getAdvance(); if (hardCodedAdvance != null) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TerritoryEffectAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TerritoryEffectAttachment.java index f5abe957ed7..66c9f2b3b81 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TerritoryEffectAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/TerritoryEffectAttachment.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import javax.annotation.Nullable; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.IntegerMap; /** @@ -25,8 +26,8 @@ */ public class TerritoryEffectAttachment extends DefaultAttachment { - public static final String COMBAT_OFFENSE_EFFECT = "combatOffenseEffect"; - public static final String COMBAT_DEFENSE_EFFECT = "combatDefenseEffect"; + @NonNls public static final String COMBAT_OFFENSE_EFFECT = "combatOffenseEffect"; + @NonNls public static final String COMBAT_DEFENSE_EFFECT = "combatDefenseEffect"; private static final long serialVersionUID = 6379810228136325991L; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java index 0cea7ef959e..0db708b24f7 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java @@ -40,6 +40,7 @@ import lombok.Getter; import lombok.Value; import lombok.experimental.Accessors; +import org.jetbrains.annotations.NonNls; import org.triplea.java.ChangeOnNextMajorRelease; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; @@ -50,23 +51,28 @@ * collection fields default to null to minimize memory use and serialization size. */ public class UnitAttachment extends DefaultAttachment { - public static final String UNITS_MAY_NOT_LAND_ON_CARRIER = "unitsMayNotLandOnCarrier"; + @NonNls public static final String UNITS_MAY_NOT_LAND_ON_CARRIER = "unitsMayNotLandOnCarrier"; + + @NonNls public static final String UNITS_MAY_NOT_LEAVE_ALLIED_CARRIER = "unitsMayNotLeaveAlliedCarrier"; - public static final String IS_SEA = "isSea"; - public static final String DEFENSE_STRENGTH = "defense"; - public static final String ATTACK_STRENGTH = "attack"; - public static final String ATTACK_ROLL = "attackRolls"; - public static final String DEFENSE_ROLL = "defenseRolls"; - public static final String ATTACK_AA = "attackAA"; - public static final String OFFENSIVE_ATTACK_AA = "offensiveAttackAA"; - public static final String MAX_AA_ATTACKS = "maxAAattacks"; - public static final String ATTACK_AA_MAX_DIE_SIDES = "attackAAmaxDieSides"; + @NonNls public static final String IS_SEA = "isSea"; + @NonNls public static final String DEFENSE_STRENGTH = "defense"; + @NonNls public static final String ATTACK_STRENGTH = "attack"; + @NonNls public static final String ATTACK_ROLL = "attackRolls"; + @NonNls public static final String DEFENSE_ROLL = "defenseRolls"; + @NonNls public static final String ATTACK_AA = "attackAA"; + @NonNls public static final String OFFENSIVE_ATTACK_AA = "offensiveAttackAA"; + @NonNls public static final String MAX_AA_ATTACKS = "maxAAattacks"; + @NonNls public static final String ATTACK_AA_MAX_DIE_SIDES = "attackAAmaxDieSides"; + + @NonNls public static final String OFFENSIVE_ATTACK_AA_MAX_DIE_SIDES = "offensiveAttackAAmaxDieSides"; - public static final String MAY_OVERSTACK_AA = "mayOverStackAA"; - public static final String IS_MARINE = "isMarine"; - public static final String BOMBARD = "bombard"; - public static final String CHOOSE_BEST_ROLL = "chooseBestRoll"; + + @NonNls public static final String MAY_OVER_STACK_AA = "mayOverStackAA"; + @NonNls public static final String IS_MARINE = "isMarine"; + @NonNls public static final String BOMBARD = "bombard"; + @NonNls public static final String CHOOSE_BEST_ROLL = "chooseBestRoll"; private static final long serialVersionUID = -2946748686268541820L; @@ -3650,7 +3656,7 @@ private static String joinRequiredUnits(final List units) { case "targetsAA": return MutableProperty.of( this::setTargetsAa, this::setTargetsAa, this::getTargetsAa, this::resetTargetsAa); - case MAY_OVERSTACK_AA: + case MAY_OVER_STACK_AA: return MutableProperty.of( this::setMayOverStackAa, this::setMayOverStackAa, diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitSupportAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitSupportAttachment.java index ce03097270b..9a028132c4b 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitSupportAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitSupportAttachment.java @@ -23,6 +23,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Value; +import org.jetbrains.annotations.NonNls; /** * An attachment for instances of {@link UnitType} that defines properties for unit types that @@ -32,10 +33,10 @@ *

The set of UnitSupportAttachments do not change during a game. */ public class UnitSupportAttachment extends DefaultAttachment { - public static final String BONUS = "bonus"; - public static final String BONUS_TYPE = "bonusType"; - public static final String DICE = "dice"; - public static final String UNIT_TYPE = "unitType"; + @NonNls public static final String BONUS = "bonus"; + @NonNls public static final String BONUS_TYPE = "bonusType"; + @NonNls public static final String DICE = "dice"; + @NonNls public static final String UNIT_TYPE = "unitType"; private static final long serialVersionUID = -3015679930172496082L; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AaInMoveUtil.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AaInMoveUtil.java index 641a6a3b130..a6422cb1330 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AaInMoveUtil.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AaInMoveUtil.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -97,14 +98,14 @@ private void fireAa( CollectionUtils.getAny(currentPossibleAa) .getUnitAttachment() .getTargetsAa(getData().getUnitTypeList()); - final Set airborneTypesTargettedToo = airborneTechTargetsAllowed.get(currentTypeAa); + final Set airborneTypesTargetedToo = airborneTechTargetsAllowed.get(currentTypeAa); final Collection validTargetedUnitsForThisRoll = CollectionUtils.getMatches( units, Matches.unitIsOfTypes(targetUnitTypesForThisTypeAa) .or( Matches.unitIsAirborne() - .and(Matches.unitIsOfTypes(airborneTypesTargettedToo)))); + .and(Matches.unitIsOfTypes(airborneTypesTargetedToo)))); // once we fire the AA guns, we can't undo // otherwise you could keep undoing and redoing until you got the roll you wanted currentMove.setCantUndo("Move cannot be undone after " + currentTypeAa + " has fired."); @@ -157,7 +158,7 @@ public void execute(final ExecutionStack stack, final IDelegateBridge bridge) { .getSoundChannelBroadcaster() .playSoundForAll( SoundPath.CLIP_BATTLE_X_PREFIX - + currentTypeAa.toLowerCase() + + currentTypeAa.toLowerCase(Locale.ROOT) + SoundPath.CLIP_BATTLE_X_MISS, defender); } @@ -179,7 +180,7 @@ public void execute(final ExecutionStack stack, final IDelegateBridge bridge) { .getSoundChannelBroadcaster() .playSoundForAll( SoundPath.CLIP_BATTLE_X_PREFIX - + currentTypeAa.toLowerCase() + + currentTypeAa.toLowerCase(Locale.ROOT) + SoundPath.CLIP_BATTLE_X_HIT, defender); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java index 890bcffe206..6f46b520a9c 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java @@ -46,6 +46,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -87,7 +88,7 @@ protected void removeUnitsThatNoLongerExist() { } // we were having a problem with units that had been killed previously were still part of // battle's variables, so we - // double check that the stuff still exists here. + // double-check that the stuff still exists here. defendingUnits.retainAll(battleSite.getUnits()); attackingUnits.retainAll(battleSite.getUnits()); targets.keySet().removeIf(unit -> !battleSite.getUnits().contains(unit)); @@ -181,7 +182,7 @@ public Change addAttackChange( public void fight(final IDelegateBridge bridge) { // remove units that may already be dead due to a previous event (like they died from a // strategic bombing raid, - // rocket attack, etc) + // rocket attack, etc.) removeUnitsThatNoLongerExist(); // we were interrupted if (stack.isExecuting()) { @@ -191,7 +192,7 @@ public void fight(final IDelegateBridge bridge) { } // We update Defending Units twice: first time when the battle is created, and second time // before the battle begins. - // The reason is because when the battle is created, there are no attacking units yet in it, + // The reason is when the battle is created, there are no attacking units yet in it, // meaning that targets // is empty. We need to update right as battle begins to know we have the full list of targets. updateDefendingUnits(); @@ -508,7 +509,8 @@ public void execute(final ExecutionStack stack, final IDelegateBridge bridge) { : SoundPath.CLIP_BATTLE_AA_MISS, defender); } else { - String prefix = SoundPath.CLIP_BATTLE_X_PREFIX + currentTypeAa.toLowerCase(); + String prefix = + SoundPath.CLIP_BATTLE_X_PREFIX + currentTypeAa.toLowerCase(Locale.ROOT); sound.playSoundForAll( prefix + (dice.getHits() > 0 diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/image/AbstractImageFactory.java b/game-app/game-core/src/main/java/games/strategy/triplea/image/AbstractImageFactory.java index b59eab382bb..d9f7ea3d047 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/image/AbstractImageFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/image/AbstractImageFactory.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; import javax.swing.ImageIcon; +import org.jetbrains.annotations.NonNls; /** Contains common methods for image factories. */ public abstract class AbstractImageFactory { @@ -28,7 +29,7 @@ private void clearImageCache() { private Image getBaseImage(final String baseImageName) { // URL uses '/' not '\' - final String fileName = getFileNameBase() + baseImageName + ".png"; + @NonNls final String fileName = getFileNameBase() + baseImageName + ".png"; final URL url = resourceLoader.getResource(fileName); if (url == null) { throw new IllegalStateException("Cant load: " + baseImageName + " looking in: " + fileName); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/image/FlagIconImageFactory.java b/game-app/game-core/src/main/java/games/strategy/triplea/image/FlagIconImageFactory.java index eeef1695ee7..932824fc365 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/image/FlagIconImageFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/image/FlagIconImageFactory.java @@ -2,37 +2,38 @@ import games.strategy.engine.data.GamePlayer; import java.awt.Image; +import org.jetbrains.annotations.NonNls; /** A factory for creating various player (nation, power, etc.) flag images. */ public class FlagIconImageFactory extends ImageFactory { - private static final String PREFIX = "flags/"; + @NonNls private static final String PREFIX = "flags/"; public Image getFlag(final GamePlayer gamePlayer) { - final String key = PREFIX + gamePlayer.getName() + ".gif"; - final String key2 = PREFIX + gamePlayer.getName() + ".png"; + @NonNls final String key = PREFIX + gamePlayer.getName() + ".gif"; + @NonNls final String key2 = PREFIX + gamePlayer.getName() + ".png"; return getImageOrThrow(key, key2); } public Image getSmallFlag(final GamePlayer gamePlayer) { - final String key = PREFIX + gamePlayer.getName() + "_small.gif"; - final String key2 = PREFIX + gamePlayer.getName() + "_small.png"; + @NonNls final String key = PREFIX + gamePlayer.getName() + "_small.gif"; + @NonNls final String key2 = PREFIX + gamePlayer.getName() + "_small.png"; return getImageOrThrow(key, key2); } public Image getLargeFlag(final GamePlayer gamePlayer) { - final String key = PREFIX + gamePlayer.getName() + "_large.png"; + @NonNls final String key = PREFIX + gamePlayer.getName() + "_large.png"; return getImageOrThrow(key); } public Image getFadedFlag(final GamePlayer gamePlayer) { - final String key = PREFIX + gamePlayer.getName() + "_fade.gif"; - final String key2 = PREFIX + gamePlayer.getName() + "_fade.png"; + @NonNls final String key = PREFIX + gamePlayer.getName() + "_fade.gif"; + @NonNls final String key2 = PREFIX + gamePlayer.getName() + "_fade.png"; return getImageOrThrow(key, key2); } public Image getConvoyFlag(final GamePlayer gamePlayer) { - final String key = PREFIX + gamePlayer.getName() + "_convoy.gif"; - final String key2 = PREFIX + gamePlayer.getName() + "_convoy.png"; + @NonNls final String key = PREFIX + gamePlayer.getName() + "_convoy.gif"; + @NonNls final String key2 = PREFIX + gamePlayer.getName() + "_convoy.png"; return getImageOrThrow(key, key2); } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/image/TileImageFactory.java b/game-app/game-core/src/main/java/games/strategy/triplea/image/TileImageFactory.java index 2069a452cc8..bef7abea3fe 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/image/TileImageFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/image/TileImageFactory.java @@ -12,6 +12,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; +import java.util.Locale; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; import javax.annotation.Nullable; @@ -52,7 +53,7 @@ public static boolean getShowMapBlends() { } private static String getShowMapBlendMode() { - return showMapBlendMode.toUpperCase(); + return showMapBlendMode.toUpperCase(Locale.ENGLISH); } private static float getShowMapBlendAlpha() { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java b/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java index 078f190ce73..1005b5b4ad4 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java @@ -37,6 +37,7 @@ import lombok.Synchronized; import lombok.Value; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; /** A factory with a thread-safe image cache for creating unit images. */ @Slf4j @@ -286,8 +287,9 @@ private Optional getBaseImageUrl(final ImageKey imageKey) { final String baseImageName = imageKey.getBaseImageName(); final GamePlayer gamePlayer = imageKey.getPlayer(); // URL uses '/' not '\' + @NonNls final String fileName = FILE_NAME_BASE + gamePlayer.getName() + "/" + baseImageName + ".png"; - final String fileName2 = FILE_NAME_BASE + baseImageName + ".png"; + @NonNls final String fileName2 = FILE_NAME_BASE + baseImageName + ".png"; final URL url = resourceLoader.getResource(fileName, fileName2); return Optional.ofNullable(url); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/NotificationMessages.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/NotificationMessages.java index 10f10f487e6..99be69da18f 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/NotificationMessages.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/NotificationMessages.java @@ -2,12 +2,13 @@ import games.strategy.triplea.ResourceLoader; import java.util.Properties; +import org.jetbrains.annotations.NonNls; /** Loads notification messages from notifications.properties. */ public class NotificationMessages { - private static final String PROPERTY_FILE = "notifications.properties"; - private static final String SOUND_CLIP_SUFFIX = "_sounds"; + @NonNls private static final String PROPERTY_FILE = "notifications.properties"; + @NonNls private static final String SOUND_CLIP_SUFFIX = "_sounds"; private final Properties properties; public NotificationMessages(final ResourceLoader resourceLoader) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ObjectiveProperties.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ObjectiveProperties.java index b9ab64e3f68..6fece103de2 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ObjectiveProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ObjectiveProperties.java @@ -4,12 +4,13 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import org.jetbrains.annotations.NonNls; /** Loads objective text from objectives.properties. */ public class ObjectiveProperties { - static final String GROUP_PROPERTY = "TABLEGROUP"; - private static final String PROPERTY_FILE = "objectives.properties"; - private static final String OBJECTIVES_PANEL_NAME = "Objectives.Panel.Name"; + @NonNls static final String GROUP_PROPERTY = "TABLEGROUP"; + @NonNls private static final String PROPERTY_FILE = "objectives.properties"; + @NonNls private static final String OBJECTIVES_PANEL_NAME = "Objectives.Panel.Name"; private final Properties properties; public ObjectiveProperties(final ResourceLoader resourceLoader) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsText.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsText.java index 5cb817f099a..398f962989f 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsText.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsText.java @@ -2,18 +2,19 @@ import games.strategy.triplea.ResourceLoader; import java.util.Properties; +import org.jetbrains.annotations.NonNls; /** Returns a bunch of messages from politicstext.properties */ public class PoliticsText { - private static final String PROPERTY_FILE = "politicstext.properties"; - private static final String BUTTON = "BUTTON"; - private static final String DESCRIPTION = "DESCRIPTION"; - private static final String NOTIFICATION_SUCCESS = "NOTIFICATION_SUCCESS"; - private static final String OTHER_NOTIFICATION_SUCCESS = "OTHER_NOTIFICATION_SUCCESS"; - private static final String NOTIFICATION_FAILURE = "NOTIFICATION_FAILURE"; - private static final String OTHER_NOTIFICATION_FAILURE = "OTHER_NOTIFICATION_FAILURE"; - private static final String ACCEPT_QUESTION = "ACCEPT_QUESTION"; + @NonNls private static final String PROPERTY_FILE = "politicstext.properties"; + @NonNls private static final String BUTTON = "BUTTON"; + @NonNls private static final String DESCRIPTION = "DESCRIPTION"; + @NonNls private static final String NOTIFICATION_SUCCESS = "NOTIFICATION_SUCCESS"; + @NonNls private static final String OTHER_NOTIFICATION_SUCCESS = "OTHER_NOTIFICATION_SUCCESS"; + @NonNls private static final String NOTIFICATION_FAILURE = "NOTIFICATION_FAILURE"; + @NonNls private static final String OTHER_NOTIFICATION_FAILURE = "OTHER_NOTIFICATION_FAILURE"; + @NonNls private static final String ACCEPT_QUESTION = "ACCEPT_QUESTION"; private final Properties properties; public PoliticsText(final ResourceLoader resourceLoader) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java index 9a3aab882f6..0f378f8bb01 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java @@ -38,6 +38,7 @@ import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.IntegerMap; import org.triplea.swing.SwingAction; import org.triplea.swing.jpanel.GridBagConstraintsBuilder; @@ -404,7 +405,7 @@ protected JPanel getPanelComponent() { final ScrollableTextField textField = new ScrollableTextField(0, Integer.MAX_VALUE); textField.setValue(quantity); - final String toolTipText = "" + tooltip + ""; + @NonNls final String toolTipText = "" + tooltip + ""; info.setToolTipText(toolTipText); label.setToolTipText(toolTipText); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionRepairPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionRepairPanel.java index 5f63a93c68e..0cb27564fb9 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionRepairPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionRepairPanel.java @@ -36,6 +36,7 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.border.EtchedBorder; +import org.jetbrains.annotations.NonNls; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; import org.triplea.swing.SwingAction; @@ -300,6 +301,7 @@ private class Rule extends JPanel { + ". Please make sure your maps are up to date!"); } repairResults = rule.getResults().getInt(type); + @NonNls final String text = " x " + ResourceCollection.toStringForHtml(cost, data) + ""; final ImageIcon icon = uiContext.getUnitImageFactory().getIcon(ImageKey.of(repairUnit)); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionTabsProperties.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionTabsProperties.java index e179490ad75..615fb11a3e6 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionTabsProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionTabsProperties.java @@ -6,31 +6,32 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; +import org.jetbrains.annotations.NonNls; import org.triplea.util.Tuple; class ProductionTabsProperties { // Filename - private static final String PROPERTY_FILE = "production_tabs"; + @NonNls private static final String PROPERTY_FILE = "production_tabs"; // Properties - private static final String USE_DEFAULT_TABS = "production_tabs.use_default_tabs"; + @NonNls private static final String USE_DEFAULT_TABS = "production_tabs.use_default_tabs"; // The number of tabs that should be drawn - private static final String NUMBER_OF_TABS = "production_tabs.number_of_tabs"; + @NonNls private static final String NUMBER_OF_TABS = "production_tabs.number_of_tabs"; // don't use production_tabs.tab_name=Air but use: // production_tabs.tab_name.1=Air // production_tabs.tab_name.2=Land - private static final String TAB_NAME = "production_tabs.tab_name"; + @NonNls private static final String TAB_NAME = "production_tabs.tab_name"; // don't use production_tabs.tab_units=Infantry:Panzer:Transport but use: // production_tabs.tab_units.1=Infantry:Panzer:Transport // production_tabs.tab_units.2=Artillery:Fighter:Bomber - private static final String TAB_UNITS = "production_tabs.tab_units"; + @NonNls private static final String TAB_UNITS = "production_tabs.tab_units"; // The number of rows of units to be used in the panel if rows or columns are "0" the system will // calculate based on // max units - private static final String NUMBER_OF_ROWS = "production_tabs.rows"; + @NonNls private static final String NUMBER_OF_ROWS = "production_tabs.rows"; // The number of columns of units to be used in the panel if rows or columns are "0" the system // will calculate based // on max units - private static final String NUMBER_OF_COLUMNS = "production_tabs.columns"; + @NonNls private static final String NUMBER_OF_COLUMNS = "production_tabs.columns"; private final Properties properties; private final List rules; private List>> ruleLists; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TooltipProperties.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TooltipProperties.java index ffbeef621fc..bb71bad1768 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TooltipProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TooltipProperties.java @@ -3,11 +3,12 @@ import games.strategy.engine.data.GamePlayer; import games.strategy.engine.data.UnitType; import java.util.Properties; +import org.jetbrains.annotations.NonNls; import org.triplea.util.LocalizeHtml; /** Generates unit tooltips based on the content of the map's {@code tooltips.properties} file. */ public final class TooltipProperties { - private static final String PROPERTY_FILE = "tooltips.properties"; + @NonNls private static final String PROPERTY_FILE = "tooltips.properties"; private static final String TOOLTIP = "tooltip"; private static final String UNIT = "unit"; private final UiContext uiContext; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UnitIconProperties.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UnitIconProperties.java index bdfa2418ced..a56a1996705 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UnitIconProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UnitIconProperties.java @@ -22,12 +22,13 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.util.FileNameUtils; /** Loads unit icons from unit_icons.properties. */ @Slf4j public final class UnitIconProperties { - private static final String PROPERTY_FILE = "unit_icons.properties"; + @NonNls private static final String PROPERTY_FILE = "unit_icons.properties"; private final Properties properties; private Map conditionsStatus = new HashMap<>(); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionText.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionText.java index 2524a12101f..181c74ce752 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionText.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionText.java @@ -2,11 +2,12 @@ import games.strategy.triplea.ResourceLoader; import java.util.Properties; +import org.jetbrains.annotations.NonNls; /** Same as PoliticsText but for user actions. */ public class UserActionText { // Filename - private static final String PROPERTY_FILE = "actionstext.properties"; + @NonNls private static final String PROPERTY_FILE = "actionstext.properties"; private static final String BUTTON = "BUTTON"; private static final String DESCRIPTION = "DESCRIPTION"; private static final String NOTIFICATION_SUCCESS = "NOTIFICATION_SUCCESS"; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/MapData.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/MapData.java index 9b4640ce8fb..956d15322ab 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/MapData.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/MapData.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.ColorUtils; import org.triplea.java.function.ThrowingFunction; import org.triplea.util.PointFileReaderWriter; @@ -40,67 +41,93 @@ /** contains data about the territories useful for drawing. */ @Slf4j public class MapData { - public static final String PROPERTY_UNITS_SCALE = "units.scale"; - public static final String PROPERTY_UNITS_WIDTH = "units.width"; - public static final String PROPERTY_UNITS_HEIGHT = "units.height"; + @NonNls public static final String PROPERTY_UNITS_SCALE = "units.scale"; + @NonNls public static final String PROPERTY_UNITS_WIDTH = "units.width"; + @NonNls public static final String PROPERTY_UNITS_HEIGHT = "units.height"; + + @NonNls public static final String PROPERTY_UNITS_COUNTER_OFFSET_WIDTH = "units.counter.offset.width"; + + @NonNls public static final String PROPERTY_UNITS_COUNTER_OFFSET_HEIGHT = "units.counter.offset.height"; - public static final String PROPERTY_UNITS_STACK_SIZE = "units.stack.size"; - public static final String PROPERTY_SCREENSHOT_TITLE_ENABLED = "screenshot.title.enabled"; - public static final String PROPERTY_SCREENSHOT_TITLE_X = "screenshot.title.x"; - public static final String PROPERTY_SCREENSHOT_TITLE_Y = "screenshot.title.y"; - public static final String PROPERTY_SCREENSHOT_TITLE_COLOR = "screenshot.title.color"; + + @NonNls public static final String PROPERTY_UNITS_STACK_SIZE = "units.stack.size"; + @NonNls public static final String PROPERTY_SCREENSHOT_TITLE_ENABLED = "screenshot.title.enabled"; + @NonNls public static final String PROPERTY_SCREENSHOT_TITLE_X = "screenshot.title.x"; + @NonNls public static final String PROPERTY_SCREENSHOT_TITLE_Y = "screenshot.title.y"; + @NonNls public static final String PROPERTY_SCREENSHOT_TITLE_COLOR = "screenshot.title.color"; + + @NonNls public static final String PROPERTY_SCREENSHOT_TITLE_FONT_SIZE = "screenshot.title.font.size"; - public static final String PROPERTY_MAP_WIDTH = "map.width"; - public static final String PROPERTY_MAP_HEIGHT = "map.height"; - public static final String PROPERTY_MAP_SCROLLWRAPX = "map.scrollWrapX"; - public static final String PROPERTY_MAP_SCROLLWRAPY = "map.scrollWrapY"; - public static final String PROPERTY_MAP_HASRELIEF = "map.hasRelief"; - public static final String PROPERTY_MAP_CURSOR_HOTSPOT_X = "map.cursor.hotspot.x"; - public static final String PROPERTY_MAP_CURSOR_HOTSPOT_Y = "map.cursor.hotspot.y"; - public static final String PROPERTY_MAP_SHOWCAPITOLMARKERS = "map.showCapitolMarkers"; + + @NonNls public static final String PROPERTY_MAP_WIDTH = "map.width"; + @NonNls public static final String PROPERTY_MAP_HEIGHT = "map.height"; + @NonNls public static final String PROPERTY_MAP_SCROLLWRAPX = "map.scrollWrapX"; + @NonNls public static final String PROPERTY_MAP_SCROLLWRAPY = "map.scrollWrapY"; + @NonNls public static final String PROPERTY_MAP_HASRELIEF = "map.hasRelief"; + @NonNls public static final String PROPERTY_MAP_CURSOR_HOTSPOT_X = "map.cursor.hotspot.x"; + @NonNls public static final String PROPERTY_MAP_CURSOR_HOTSPOT_Y = "map.cursor.hotspot.y"; + @NonNls public static final String PROPERTY_MAP_SHOWCAPITOLMARKERS = "map.showCapitolMarkers"; public static final String PROPERTY_MAP_USETERRITORYEFFECTMARKERS = "map.useTerritoryEffectMarkers"; - public static final String PROPERTY_MAP_SHOWTERRITORYNAMES = "map.showTerritoryNames"; - public static final String PROPERTY_MAP_SHOWRESOURCES = "map.showResources"; - public static final String PROPERTY_MAP_SHOWCOMMENTS = "map.showComments"; - public static final String PROPERTY_MAP_SHOWSEAZONENAMES = "map.showSeaZoneNames"; - public static final String PROPERTY_MAP_DRAWNAMESFROMTOPLEFT = "map.drawNamesFromTopLeft"; + @NonNls public static final String PROPERTY_MAP_SHOWTERRITORYNAMES = "map.showTerritoryNames"; + @NonNls public static final String PROPERTY_MAP_SHOWRESOURCES = "map.showResources"; + @NonNls public static final String PROPERTY_MAP_SHOWCOMMENTS = "map.showComments"; + @NonNls public static final String PROPERTY_MAP_SHOWSEAZONENAMES = "map.showSeaZoneNames"; + @NonNls public static final String PROPERTY_MAP_DRAWNAMESFROMTOPLEFT = "map.drawNamesFromTopLeft"; + + @NonNls public static final String PROPERTY_MAP_USENATION_CONVOYFLAGS = "map.useNation_convoyFlags"; + public static final String PROPERTY_DONT_DRAW_TERRITORY_NAMES = "dont_draw_territory_names"; - public static final String PROPERTY_MAP_MAPBLENDS = "map.mapBlends"; - public static final String PROPERTY_MAP_MAPBLENDMODE = "map.mapBlendMode"; - public static final String PROPERTY_MAP_MAPBLENDALPHA = "map.mapBlendAlpha"; + @NonNls public static final String PROPERTY_MAP_MAPBLENDS = "map.mapBlends"; + @NonNls public static final String PROPERTY_MAP_MAPBLENDMODE = "map.mapBlendMode"; + @NonNls public static final String PROPERTY_MAP_MAPBLENDALPHA = "map.mapBlendAlpha"; + + @NonNls public static final String POLYGON_FILE = "polygons.txt"; - public static final String POLYGON_FILE = "polygons.txt"; + @NonNls private static final String PROPERTY_DONT_DRAW_UNITS = "dont_draw_units"; - private static final String PROPERTY_DONT_DRAW_UNITS = "dont_draw_units"; + @NonNls private static final String PROPERTY_MAP_SMALLMAPTERRITORYSATURATION = "smallMap.territory.saturation"; - private static final String PROPERTY_MAP_SMALLMAPUNITSIZE = "smallMap.unit.size"; + + @NonNls private static final String PROPERTY_MAP_SMALLMAPUNITSIZE = "smallMap.unit.size"; + + @NonNls private static final String PROPERTY_MAP_SMALLMAPVIEWERBORDERCOLOR = "smallMap.viewer.borderColor"; + + @NonNls private static final String PROPERTY_MAP_SMALLMAPVIEWERFILLCOLOR = "smallMap.viewer.fillColor"; + + @NonNls private static final String PROPERTY_MAP_SMALLMAPVIEWERFILLALPHA = "smallMap.viewer.fillAlpha"; + + @NonNls private static final String PROPERTY_UNITS_TRANSFORM_COLOR_PREFIX = "units.transform.color."; + private static final String PROPERTY_UNITS_TRANSFORM_BRIGHTNESS_PREFIX = "units.transform.brightness."; + + @NonNls private static final String PROPERTY_UNITS_TRANSFORM_FLIP_PREFIX = "units.transform.flip."; - private static final String PROPERTY_UNITS_TRANSFORM_IGNORE = "units.transform.ignore"; - - private static final String CENTERS_FILE = "centers.txt"; - private static final String PLACEMENT_FILE = "place.txt"; - private static final String TERRITORY_EFFECT_FILE = "territory_effects.txt"; - private static final String MAP_PROPERTIES = "map.properties"; - private static final String CAPITAL_MARKERS = "capitols.txt"; - private static final String CONVOY_MARKERS = "convoy.txt"; - private static final String COMMENT_MARKERS = "comments.txt"; - private static final String VC_MARKERS = "vc.txt"; - private static final String BLOCKADE_MARKERS = "blockade.txt"; - private static final String PU_PLACE_FILE = "pu_place.txt"; - private static final String TERRITORY_NAME_PLACE_FILE = "name_place.txt"; - private static final String KAMIKAZE_FILE = "kamikaze_place.txt"; - private static final String DECORATIONS_FILE = "decorations.txt"; + + @NonNls private static final String PROPERTY_UNITS_TRANSFORM_IGNORE = "units.transform.ignore"; + + @NonNls private static final String CENTERS_FILE = "centers.txt"; + @NonNls private static final String PLACEMENT_FILE = "place.txt"; + @NonNls private static final String TERRITORY_EFFECT_FILE = "territory_effects.txt"; + @NonNls private static final String MAP_PROPERTIES = "map.properties"; + @NonNls private static final String CAPITAL_MARKERS = "capitols.txt"; + @NonNls private static final String CONVOY_MARKERS = "convoy.txt"; + @NonNls private static final String COMMENT_MARKERS = "comments.txt"; + @NonNls private static final String VC_MARKERS = "vc.txt"; + @NonNls private static final String BLOCKADE_MARKERS = "blockade.txt"; + @NonNls private static final String PU_PLACE_FILE = "pu_place.txt"; + @NonNls private static final String TERRITORY_NAME_PLACE_FILE = "name_place.txt"; + @NonNls private static final String KAMIKAZE_FILE = "kamikaze_place.txt"; + @NonNls private static final String DECORATIONS_FILE = "decorations.txt"; private final PlayerColors playerColors; private Set ignoreTransformingUnits; @@ -753,8 +780,8 @@ public Optional getTerritoryEffectImage(final String effectName) { effectImages.computeIfAbsent( effectName, key -> { - String largeImageName = "territoryEffects/" + effectName + "_large.png"; - String standardImageName = "territoryEffects/" + effectName + ".png"; + @NonNls String largeImageName = "territoryEffects/" + effectName + "_large.png"; + @NonNls String standardImageName = "territoryEffects/" + effectName + ".png"; return loader .loadImage(largeImageName) diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/PlayerColors.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/PlayerColors.java index 732c9308fe0..9175ccd8e16 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/PlayerColors.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/mapdata/PlayerColors.java @@ -10,13 +10,14 @@ import java.util.Optional; import java.util.Properties; import lombok.RequiredArgsConstructor; +import org.jetbrains.annotations.NonNls; import org.triplea.java.ColorUtils; @RequiredArgsConstructor public final class PlayerColors { - public static final String PROPERTY_COLOR_PREFIX = "color."; - public static final String PLAYER_NAME_IMPASSABLE = "Impassable"; - public static final String PLAYER_NAME_IMPASSABLE_LEGACY_SPELLING = "Impassible"; + @NonNls public static final String PROPERTY_COLOR_PREFIX = "color."; + @NonNls public static final String PLAYER_NAME_IMPASSABLE = "Impassable"; + @NonNls public static final String PLAYER_NAME_IMPASSABLE_LEGACY_SPELLING = "Impassible"; public static final Color DEFAULT_IMPASSABLE_COLOR = ColorUtils.fromHexString("DEB887"); @VisibleForTesting diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/unit/scroller/UnitScrollerIcon.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/unit/scroller/UnitScrollerIcon.java index 25a7d21d510..4f763276f6e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/unit/scroller/UnitScrollerIcon.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/unit/scroller/UnitScrollerIcon.java @@ -8,6 +8,7 @@ import javax.swing.ImageIcon; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import org.jetbrains.annotations.NonNls; /** Class to handle icon paths and getting references to Icon images. */ @AllArgsConstructor(access = AccessLevel.PRIVATE) @@ -18,7 +19,7 @@ class UnitScrollerIcon implements Supplier { static final UnitScrollerIcon SKIP = new UnitScrollerIcon("skip.png"); static final UnitScrollerIcon WAKE_ALL = new UnitScrollerIcon("wake_all.png"); - private static final String UNIT_SCROLLER_IMAGES_FOLDER = "unit_scroller"; + @NonNls private static final String UNIT_SCROLLER_IMAGES_FOLDER = "unit_scroller"; private final String imageFile; diff --git a/game-app/game-core/src/main/java/org/triplea/security/DefaultCredentialManager.java b/game-app/game-core/src/main/java/org/triplea/security/DefaultCredentialManager.java index 2a7af2cb423..b9183652c85 100644 --- a/game-app/game-core/src/main/java/org/triplea/security/DefaultCredentialManager.java +++ b/game-app/game-core/src/main/java/org/triplea/security/DefaultCredentialManager.java @@ -20,6 +20,7 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; +import org.jetbrains.annotations.NonNls; /** * Default implementation of {@link CredentialManager}. @@ -30,10 +31,10 @@ * if it does not exist. */ final class DefaultCredentialManager implements CredentialManager { - @VisibleForTesting + @VisibleForTesting @NonNls static final String PREFERENCE_KEY_MASTER_PASSWORD = "DEFAULT_CREDENTIAL_MANAGER_MASTER_PASSWORD"; - private static final String CIPHER_ALGORITHM = "AES"; + @NonNls private static final String CIPHER_ALGORITHM = "AES"; private final char[] masterPassword; diff --git a/game-app/game-core/src/main/java/org/triplea/sound/ClipPlayer.java b/game-app/game-core/src/main/java/org/triplea/sound/ClipPlayer.java index 25e23c8e9a6..a3d10512f0f 100644 --- a/game-app/game-core/src/main/java/org/triplea/sound/ClipPlayer.java +++ b/game-app/game-core/src/main/java/org/triplea/sound/ClipPlayer.java @@ -28,6 +28,7 @@ import javazoom.jl.player.FactoryRegistry; import javazoom.jl.player.advanced.AdvancedPlayer; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.ThreadRunner; import org.triplea.java.UrlStreams; @@ -108,9 +109,9 @@ */ @Slf4j public class ClipPlayer { - private static final String ASSETS_SOUNDS_FOLDER = "sounds"; - private static final String SOUND_PREFERENCE_PREFIX = "sound_"; - private static final String MP3_SUFFIX = ".mp3"; + @NonNls private static final String ASSETS_SOUNDS_FOLDER = "sounds"; + @NonNls private static final String SOUND_PREFERENCE_PREFIX = "sound_"; + @NonNls private static final String MP3_SUFFIX = ".mp3"; private static final Set mutedClips = ConcurrentHashMap.newKeySet(); @@ -290,7 +291,7 @@ private List parseClipPaths(final String pathName) { availableSounds.addAll(findClipFiles(ASSETS_SOUNDS_FOLDER + "/" + path)); } if (availableSounds.isEmpty()) { - final String genericPath = SoundProperties.GENERIC_FOLDER + "/" + pathName; + @NonNls final String genericPath = SoundProperties.GENERIC_FOLDER + "/" + pathName; availableSounds.addAll(findClipFiles(ASSETS_SOUNDS_FOLDER + "/" + genericPath)); } return availableSounds; diff --git a/game-app/game-core/src/main/java/org/triplea/sound/SoundPath.java b/game-app/game-core/src/main/java/org/triplea/sound/SoundPath.java index cd2de029144..09261ec6a29 100644 --- a/game-app/game-core/src/main/java/org/triplea/sound/SoundPath.java +++ b/game-app/game-core/src/main/java/org/triplea/sound/SoundPath.java @@ -5,65 +5,69 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.jetbrains.annotations.NonNls; /** Contains the sound file names and the directory of all sound files. */ public final class SoundPath { // MAKE SURE TO ADD NEW SOUNDS TO THE getAllSoundOptions() METHOD! (or else the user's preference // will not be saved) - public static final String CLIP_BATTLE_X_HIT = "_hit"; - public static final String CLIP_BATTLE_X_MISS = "_miss"; - public static final String CLIP_BATTLE_X_PREFIX = "battle_"; - public static final String CLIP_CHAT_MESSAGE = "chat_message"; - public static final String CLIP_CHAT_SLAP = "chat_slap"; - public static final String CLIP_CHAT_JOIN_GAME = "chat_join_game"; - public static final String CLIP_CLICK_BUTTON = "click_button"; - public static final String CLIP_TRIGGERED_DEFEAT_SOUND = "defeat_"; - public static final String CLIP_TRIGGERED_VICTORY_SOUND = "victory_"; - public static final String CLIP_BATTLE_AA_HIT = "battle_aa_hit"; - public static final String CLIP_BATTLE_AA_MISS = "battle_aa_miss"; - public static final String CLIP_BATTLE_AIR = "battle_air"; - public static final String CLIP_BATTLE_AIR_SUCCESSFUL = "battle_air_successful"; - public static final String CLIP_BATTLE_BOMBARD = "battle_bombard"; - public static final String CLIP_BATTLE_FAILURE = "battle_failure"; - public static final String CLIP_BATTLE_LAND = "battle_land"; - public static final String CLIP_BATTLE_RETREAT_AIR = "battle_retreat_air"; - public static final String CLIP_BATTLE_RETREAT_LAND = "battle_retreat_land"; - public static final String CLIP_BATTLE_RETREAT_SEA = "battle_retreat_sea"; - public static final String CLIP_BATTLE_RETREAT_SUBMERGE = "battle_retreat_submerge"; - public static final String CLIP_BATTLE_SEA_NORMAL = "battle_sea_normal"; - public static final String CLIP_BATTLE_SEA_SUBS = "battle_sea_subs"; - public static final String CLIP_BATTLE_SEA_SUCCESSFUL = "battle_sea_successful"; - public static final String CLIP_BATTLE_STALEMATE = "battle_stalemate"; - public static final String CLIP_BOMBING_ROCKET = "bombing_rocket"; - public static final String CLIP_BOMBING_STRATEGIC = "bombing_strategic"; - public static final String CLIP_GAME_START = "game_start"; - public static final String CLIP_GAME_WON = "game_won"; - public static final String CLIP_TRIGGERED_NOTIFICATION_SOUND = "notification_"; - public static final String CLIP_PHASE_BATTLE = "phase_battle"; - public static final String CLIP_PHASE_END_TURN = "phase_end_turn"; - public static final String CLIP_PHASE_MOVE_COMBAT = "phase_move_combat"; - public static final String CLIP_PHASE_MOVE_NONCOMBAT = "phase_move_noncombat"; - public static final String CLIP_PHASE_PLACEMENT = "phase_placement"; - public static final String CLIP_PHASE_POLITICS = "phase_politics"; - public static final String CLIP_PHASE_PURCHASE = "phase_purchase"; - public static final String CLIP_PHASE_TECHNOLOGY = "phase_technology"; - public static final String CLIP_PHASE_USER_ACTIONS = "phase_user_actions"; - public static final String CLIP_PLACED_AIR = "placed_air"; - public static final String CLIP_PLACED_INFRASTRUCTURE = "placed_infrastructure"; - public static final String CLIP_PLACED_LAND = "placed_land"; - public static final String CLIP_PLACED_SEA = "placed_sea"; - public static final String CLIP_POLITICAL_ACTION_FAILURE = "political_action_failure"; + @NonNls public static final String CLIP_BATTLE_X_HIT = "_hit"; + @NonNls public static final String CLIP_BATTLE_X_MISS = "_miss"; + @NonNls public static final String CLIP_BATTLE_X_PREFIX = "battle_"; + @NonNls public static final String CLIP_CHAT_MESSAGE = "chat_message"; + @NonNls public static final String CLIP_CHAT_SLAP = "chat_slap"; + @NonNls public static final String CLIP_CHAT_JOIN_GAME = "chat_join_game"; + @NonNls public static final String CLIP_CLICK_BUTTON = "click_button"; + @NonNls public static final String CLIP_TRIGGERED_DEFEAT_SOUND = "defeat_"; + @NonNls public static final String CLIP_TRIGGERED_VICTORY_SOUND = "victory_"; + @NonNls public static final String CLIP_BATTLE_AA_HIT = "battle_aa_hit"; + @NonNls public static final String CLIP_BATTLE_AA_MISS = "battle_aa_miss"; + @NonNls public static final String CLIP_BATTLE_AIR = "battle_air"; + @NonNls public static final String CLIP_BATTLE_AIR_SUCCESSFUL = "battle_air_successful"; + @NonNls public static final String CLIP_BATTLE_BOMBARD = "battle_bombard"; + @NonNls public static final String CLIP_BATTLE_FAILURE = "battle_failure"; + @NonNls public static final String CLIP_BATTLE_LAND = "battle_land"; + @NonNls public static final String CLIP_BATTLE_RETREAT_AIR = "battle_retreat_air"; + @NonNls public static final String CLIP_BATTLE_RETREAT_LAND = "battle_retreat_land"; + @NonNls public static final String CLIP_BATTLE_RETREAT_SEA = "battle_retreat_sea"; + @NonNls public static final String CLIP_BATTLE_RETREAT_SUBMERGE = "battle_retreat_submerge"; + @NonNls public static final String CLIP_BATTLE_SEA_NORMAL = "battle_sea_normal"; + @NonNls public static final String CLIP_BATTLE_SEA_SUBS = "battle_sea_subs"; + @NonNls public static final String CLIP_BATTLE_SEA_SUCCESSFUL = "battle_sea_successful"; + @NonNls public static final String CLIP_BATTLE_STALEMATE = "battle_stalemate"; + @NonNls public static final String CLIP_BOMBING_ROCKET = "bombing_rocket"; + @NonNls public static final String CLIP_BOMBING_STRATEGIC = "bombing_strategic"; + @NonNls public static final String CLIP_GAME_START = "game_start"; + @NonNls public static final String CLIP_GAME_WON = "game_won"; + @NonNls public static final String CLIP_TRIGGERED_NOTIFICATION_SOUND = "notification_"; + @NonNls public static final String CLIP_PHASE_BATTLE = "phase_battle"; + @NonNls public static final String CLIP_PHASE_END_TURN = "phase_end_turn"; + @NonNls public static final String CLIP_PHASE_MOVE_COMBAT = "phase_move_combat"; + @NonNls public static final String CLIP_PHASE_MOVE_NONCOMBAT = "phase_move_noncombat"; + @NonNls public static final String CLIP_PHASE_PLACEMENT = "phase_placement"; + @NonNls public static final String CLIP_PHASE_POLITICS = "phase_politics"; + @NonNls public static final String CLIP_PHASE_PURCHASE = "phase_purchase"; + @NonNls public static final String CLIP_PHASE_TECHNOLOGY = "phase_technology"; + @NonNls public static final String CLIP_PHASE_USER_ACTIONS = "phase_user_actions"; + @NonNls public static final String CLIP_PLACED_AIR = "placed_air"; + @NonNls public static final String CLIP_PLACED_INFRASTRUCTURE = "placed_infrastructure"; + @NonNls public static final String CLIP_PLACED_LAND = "placed_land"; + @NonNls public static final String CLIP_PLACED_SEA = "placed_sea"; + @NonNls public static final String CLIP_POLITICAL_ACTION_FAILURE = "political_action_failure"; + + @NonNls public static final String CLIP_POLITICAL_ACTION_SUCCESSFUL = "political_action_successful"; - public static final String CLIP_REQUIRED_YOUR_TURN_SERIES = "required_your_turn_series"; - public static final String CLIP_TECHNOLOGY_FAILURE = "technology_failure"; - public static final String CLIP_TECHNOLOGY_SUCCESSFUL = "technology_successful"; - public static final String CLIP_TERRITORY_CAPTURE_BLITZ = "territory_capture_blitz"; - public static final String CLIP_TERRITORY_CAPTURE_CAPITAL = "territory_capture_capital"; - public static final String CLIP_TERRITORY_CAPTURE_LAND = "territory_capture_land"; - public static final String CLIP_TERRITORY_CAPTURE_SEA = "territory_capture_sea"; - public static final String CLIP_USER_ACTION_FAILURE = "user_action_failure"; - public static final String CLIP_USER_ACTION_SUCCESSFUL = "user_action_successful"; + + @NonNls public static final String CLIP_REQUIRED_YOUR_TURN_SERIES = "required_your_turn_series"; + @NonNls public static final String CLIP_TECHNOLOGY_FAILURE = "technology_failure"; + @NonNls public static final String CLIP_TECHNOLOGY_SUCCESSFUL = "technology_successful"; + @NonNls public static final String CLIP_TERRITORY_CAPTURE_BLITZ = "territory_capture_blitz"; + @NonNls public static final String CLIP_TERRITORY_CAPTURE_CAPITAL = "territory_capture_capital"; + @NonNls public static final String CLIP_TERRITORY_CAPTURE_LAND = "territory_capture_land"; + @NonNls public static final String CLIP_TERRITORY_CAPTURE_SEA = "territory_capture_sea"; + @NonNls public static final String CLIP_USER_ACTION_FAILURE = "user_action_failure"; + @NonNls public static final String CLIP_USER_ACTION_SUCCESSFUL = "user_action_successful"; private SoundPath() {} diff --git a/game-app/game-core/src/main/java/org/triplea/sound/SoundProperties.java b/game-app/game-core/src/main/java/org/triplea/sound/SoundProperties.java index b37eb6ef9f5..30bf60a9422 100644 --- a/game-app/game-core/src/main/java/org/triplea/sound/SoundProperties.java +++ b/game-app/game-core/src/main/java/org/triplea/sound/SoundProperties.java @@ -2,13 +2,14 @@ import games.strategy.triplea.ResourceLoader; import java.util.Properties; +import org.jetbrains.annotations.NonNls; /** sounds.properties file helper class */ class SoundProperties { - static final String GENERIC_FOLDER = "generic"; - private static final String PROPERTY_FILE = "sounds.properties"; - private static final String PROPERTY_DEFAULT_FOLDER = "Sound.Default.Folder"; - private static final String DEFAULT_ERA_FOLDER = "ww2"; + @NonNls static final String GENERIC_FOLDER = "generic"; + @NonNls private static final String PROPERTY_FILE = "sounds.properties"; + @NonNls private static final String PROPERTY_DEFAULT_FOLDER = "Sound.Default.Folder"; + @NonNls private static final String DEFAULT_ERA_FOLDER = "ww2"; private final Properties properties; SoundProperties(final ResourceLoader loader) { diff --git a/game-app/game-core/src/main/java/org/triplea/sound/SoundUtils.java b/game-app/game-core/src/main/java/org/triplea/sound/SoundUtils.java index 5cf70a38752..05ae06c23a9 100644 --- a/game-app/game-core/src/main/java/org/triplea/sound/SoundUtils.java +++ b/game-app/game-core/src/main/java/org/triplea/sound/SoundUtils.java @@ -7,6 +7,7 @@ import games.strategy.triplea.delegate.battle.MustFightBattle.RetreatType; import java.util.Collection; import java.util.List; +import java.util.Locale; /** Contains methods to play various sound clips. */ public final class SoundUtils { @@ -65,14 +66,16 @@ public static void playFireBattleAa( bridge .getSoundChannelBroadcaster() .playSoundForAll( - SoundPath.CLIP_BATTLE_X_PREFIX + aaType.toLowerCase() + SoundPath.CLIP_BATTLE_X_HIT, + SoundPath.CLIP_BATTLE_X_PREFIX + + aaType.toLowerCase(Locale.ROOT) + + SoundPath.CLIP_BATTLE_X_HIT, firingPlayer); } else { bridge .getSoundChannelBroadcaster() .playSoundForAll( SoundPath.CLIP_BATTLE_X_PREFIX - + aaType.toLowerCase() + + aaType.toLowerCase(Locale.ROOT) + SoundPath.CLIP_BATTLE_X_MISS, firingPlayer); } diff --git a/game-app/game-core/src/main/java/org/triplea/util/FileNameUtils.java b/game-app/game-core/src/main/java/org/triplea/util/FileNameUtils.java index b43e2e4b164..7f14b0c6dc9 100644 --- a/game-app/game-core/src/main/java/org/triplea/util/FileNameUtils.java +++ b/game-app/game-core/src/main/java/org/triplea/util/FileNameUtils.java @@ -4,10 +4,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.CharMatcher; +import org.jetbrains.annotations.NonNls; /** A collection of useful methods for working with file names. */ public final class FileNameUtils { - @VisibleForTesting static final String ILLEGAL_CHARACTERS = "/\b\n\r\t\0\f`?*\\<>|\"':.,^[]=+;"; + @VisibleForTesting @NonNls + static final String ILLEGAL_CHARACTERS = "/\b\n\r\t\0\f`?*\\<>|\"':.,^[]=+;"; private static final CharMatcher ILLEGAL_CHAR_MATCHER = CharMatcher.anyOf(ILLEGAL_CHARACTERS); diff --git a/game-app/game-core/src/main/java/tools/image/AutoPlacementFinder.java b/game-app/game-core/src/main/java/tools/image/AutoPlacementFinder.java index b05831b4eb9..042651b74f9 100644 --- a/game-app/game-core/src/main/java/tools/image/AutoPlacementFinder.java +++ b/game-app/game-core/src/main/java/tools/image/AutoPlacementFinder.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Scanner; import java.util.Set; @@ -27,6 +28,7 @@ import javax.swing.JPanel; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.util.PointFileReaderWriter; import tools.util.ToolArguments; @@ -84,7 +86,7 @@ private void runInternal() { + "final place." + "
Example: the map folder should have a name, with the 2 text files already " + "in that folder, and " - + "
the folder should be located in your users\\yourname\\triplea\\maps\\ " + + "
the folder should be located in your users\\username\\triplea\\maps\\ " + "directory." + "

The program will ask for the folder name (just the name, not the " + "full path)." @@ -125,9 +127,9 @@ private void calculate() { int height = unitHeight; boolean found = false; try (Scanner scanner = new Scanner(file, StandardCharsets.UTF_8.name())) { - final String heightProperty = MapData.PROPERTY_UNITS_HEIGHT + "="; - final String widthProperty = MapData.PROPERTY_UNITS_WIDTH + "="; - final String scaleProperty = MapData.PROPERTY_UNITS_SCALE + "="; + @NonNls final String heightProperty = MapData.PROPERTY_UNITS_HEIGHT + "="; + @NonNls final String widthProperty = MapData.PROPERTY_UNITS_WIDTH + "="; + @NonNls final String scaleProperty = MapData.PROPERTY_UNITS_SCALE + "="; while (scanner.hasNextLine()) { final String line = scanner.nextLine(); if (line.contains(scaleProperty)) { @@ -214,7 +216,7 @@ private void calculate() { try { final String result = getUnitsScale(); try { - unitZoomPercent = Double.parseDouble(result.toLowerCase()); + unitZoomPercent = Double.parseDouble(result.toLowerCase(Locale.ROOT)); } catch (final NumberFormatException ex) { // ignore malformed input } @@ -287,7 +289,7 @@ private void calculate() { } /** - * we need the exact map name as indicated in the XML game file ie. "revised" "classic" + * we need the exact map name as indicated in the XML game file i.e. "revised" "classic" * "pact_of_steel" of course, without the quotes. */ private static String getMapDirectory() { @@ -325,7 +327,7 @@ private static String getUnitsScale() { private List getPlacementsStartingAtMiddle( final Collection countryPolygons, final Rectangle bounding, final Point center) { - final List placementRects = new ArrayList<>(); + final List placementRectangles = new ArrayList<>(); final List placementPoints = new ArrayList<>(); final Rectangle2D place = new Rectangle2D.Double(center.x, center.y, placeHeight, placeWidth); int x = center.x - (placeHeight / 2); @@ -338,7 +340,7 @@ private List getPlacementsStartingAtMiddle( } else { x--; } - isPlacement(countryPolygons, Set.of(), placementRects, placementPoints, place, x, y); + isPlacement(countryPolygons, Set.of(), placementRectangles, placementPoints, place, x, y); } for (int j = 0; j < Math.abs(step); j++) { if (step > 0) { @@ -346,7 +348,7 @@ private List getPlacementsStartingAtMiddle( } else { y--; } - isPlacement(countryPolygons, Set.of(), placementRects, placementPoints, place, x, y); + isPlacement(countryPolygons, Set.of(), placementRectangles, placementPoints, place, x, y); } step = -step; if (step > 0) { @@ -361,9 +363,9 @@ private List getPlacementsStartingAtMiddle( } } if (placementPoints.isEmpty()) { - final int defaultx = center.x - (placeHeight / 2); - final int defaulty = center.y - (placeWidth / 2); - placementPoints.add(new Point(defaultx, defaulty)); + final int defaultX = center.x - (placeHeight / 2); + final int defaultY = center.y - (placeWidth / 2); + placementPoints.add(new Point(defaultX, defaultY)); } return placementPoints; } @@ -373,7 +375,7 @@ private List getPlacementsStartingAtTopLeft( final Rectangle bounding, final Point center, final Collection containedCountryPolygons) { - final List placementRects = new ArrayList<>(); + final List placementRectangles = new ArrayList<>(); final List placementPoints = new ArrayList<>(); final Rectangle2D place = new Rectangle2D.Double(center.x, center.y, placeHeight, placeWidth); for (int x = bounding.x + 1; x < bounding.width + bounding.x; x++) { @@ -381,7 +383,7 @@ private List getPlacementsStartingAtTopLeft( isPlacement( countryPolygons, containedCountryPolygons, - placementRects, + placementRectangles, placementPoints, place, x, @@ -392,9 +394,9 @@ private List getPlacementsStartingAtTopLeft( } } if (placementPoints.isEmpty()) { - final int defaultx = center.x - (placeHeight / 2); - final int defaulty = center.y - (placeWidth / 2); - placementPoints.add(new Point(defaultx, defaulty)); + final int defaultX = center.x - (placeHeight / 2); + final int defaultY = center.y - (placeWidth / 2); + placementPoints.add(new Point(defaultX, defaultY)); } return placementPoints; } @@ -402,7 +404,7 @@ private List getPlacementsStartingAtTopLeft( private void isPlacement( final Collection countryPolygons, final Collection containedCountryPolygons, - final List placementRects, + final List placementRectangles, final List placementPoints, final Rectangle2D place, final int x, @@ -410,13 +412,13 @@ private void isPlacement( place.setFrame(x, y, placeWidth, placeHeight); // make sure it is not in or intersects the contained country if (containedIn(place, countryPolygons) - && !intersectsOneOf(place, placementRects) + && !intersectsOneOf(place, placementRectangles) && (!containedIn(place, containedCountryPolygons) && !intersectsOneOf(place, containedCountryPolygons))) { placementPoints.add(new Point((int) place.getX(), (int) place.getY())); final Rectangle2D newRect = new Rectangle2D.Double(); newRect.setFrame(place); - placementRects.add(newRect); + placementRectangles.add(newRect); } // if } diff --git a/game-app/game-core/src/main/java/tools/image/TileImageReconstructor.java b/game-app/game-core/src/main/java/tools/image/TileImageReconstructor.java index 95ef4936d9b..0ff7752ee41 100644 --- a/game-app/game-core/src/main/java/tools/image/TileImageReconstructor.java +++ b/game-app/game-core/src/main/java/tools/image/TileImageReconstructor.java @@ -30,6 +30,7 @@ import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.util.PointFileReaderWriter; /** For taking a folder of basetiles and putting them back together into an image. */ @@ -170,7 +171,7 @@ private void createMap() { final Graphics graphics = mapImage.getGraphics(); for (int x = 0; x * TILE_SIZE < sizeX; x++) { for (int y = 0; y * TILE_SIZE < sizeY; y++) { - final String tileName = x + "_" + y + ".png"; + @NonNls final String tileName = x + "_" + y + ".png"; final Path tileFile = baseTileLocation.resolve(tileName); if (!Files.exists(tileFile)) { continue; diff --git a/game-app/game-core/src/main/java/tools/map/making/ConnectionFinder.java b/game-app/game-core/src/main/java/tools/map/making/ConnectionFinder.java index 30e29728909..ec7cb3d53a0 100644 --- a/game-app/game-core/src/main/java/tools/map/making/ConnectionFinder.java +++ b/game-app/game-core/src/main/java/tools/map/making/ConnectionFinder.java @@ -29,6 +29,7 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.AlphanumComparator; import org.triplea.util.PointFileReaderWriter; import tools.image.FileOpen; @@ -42,20 +43,20 @@ */ @Slf4j public final class ConnectionFinder { - private static final String LINE_THICKNESS = "triplea.map.lineThickness"; - private static final String SCALE_PIXELS = "triplea.map.scalePixels"; - private static final String MIN_OVERLAP = "triplea.map.minOverlap"; + @NonNls private static final String LINE_THICKNESS = "triplea.map.lineThickness"; + @NonNls private static final String SCALE_PIXELS = "triplea.map.scalePixels"; + @NonNls private static final String MIN_OVERLAP = "triplea.map.minOverlap"; private Path mapFolderLocation = null; private boolean dimensionsSet = false; private StringBuilder territoryDefinitions = null; - // how many pixels should each area become bigger in both x and y axis to see which area it + // how many pixels should each area become bigger in both x- and y-axis to see which area it // overlaps? - // default 8, or if LINE_THICKNESS if given 4x linethickness + // default 8, or if LINE_THICKNESS if given 4x line thickness private int scalePixels = 8; - // how many pixels should the boundingbox of the overlapping area have for it to be considered a + // how many pixels should the bounding box of the overlapping area have for it to be considered a // valid connection? - // default 32, or if LINE_THICKNESS is given 16 x linethickness + // default 32, or if LINE_THICKNESS is given 16 x line thickness private double minOverlap = 32.0; /** @@ -404,9 +405,9 @@ private static Shape scale(final Shape currentShape, final int pixels) { } /** - * from: eu.hansolo.steelseries.tools.Scaler.java Returns a scaled version of the given shape, - * calculated by the given scale factor. The scaling will be calculated around the centroid of the - * shape. + * from: {@code eu.hansolo.steelseries.tools.Scaler.java} Returns a scaled version of the given + * shape, calculated by the given scale factor. The scaling will be calculated around the centroid + * of the shape. * * @param sx how much to scale on the x-axis * @param sy how much to scale on the y-axis diff --git a/game-app/game-core/src/main/java/tools/map/making/PlacementPicker.java b/game-app/game-core/src/main/java/tools/map/making/PlacementPicker.java index 94b5991ee3c..b097b36161e 100644 --- a/game-app/game-core/src/main/java/tools/map/making/PlacementPicker.java +++ b/game-app/game-core/src/main/java/tools/map/making/PlacementPicker.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; @@ -43,6 +44,7 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.swing.SwingAction; import org.triplea.util.PointFileReaderWriter; import org.triplea.util.Tuple; @@ -176,9 +178,9 @@ private final class PlacementPickerFrame extends JFrame { int width = unitWidth; int height = unitHeight; boolean found = false; - final String scaleProperty = MapData.PROPERTY_UNITS_SCALE + "="; - final String widthProperty = MapData.PROPERTY_UNITS_WIDTH + "="; - final String heightProperty = MapData.PROPERTY_UNITS_HEIGHT + "="; + @NonNls final String scaleProperty = MapData.PROPERTY_UNITS_SCALE + "="; + @NonNls final String widthProperty = MapData.PROPERTY_UNITS_WIDTH + "="; + @NonNls final String heightProperty = MapData.PROPERTY_UNITS_HEIGHT + "="; try (Scanner scanner = new Scanner(file, StandardCharsets.UTF_8.name())) { while (scanner.hasNextLine()) { final String line = scanner.nextLine(); @@ -266,7 +268,7 @@ private final class PlacementPickerFrame extends JFrame { try { final String result = getUnitsScale(); try { - unitZoomPercent = Double.parseDouble(result.toLowerCase()); + unitZoomPercent = Double.parseDouble(result.toLowerCase(Locale.ROOT)); } catch (final NumberFormatException ex) { // ignore malformed input } @@ -334,7 +336,7 @@ private final class PlacementPickerFrame extends JFrame { image = FileHelper.newImage(mapFolder); final JPanel imagePanel = newMainPanel(); /* - * Add a mouse listener to show X : Y coordinates on the lower left corner of the screen. + * Add a mouse listener to show X : Y coordinates in the lower left corner of the screen. */ imagePanel.addMouseMotionListener( new MouseMotionAdapter() { diff --git a/game-app/game-core/src/main/java/tools/util/ToolArguments.java b/game-app/game-core/src/main/java/tools/util/ToolArguments.java index 862197c503f..2e12e0afc75 100644 --- a/game-app/game-core/src/main/java/tools/util/ToolArguments.java +++ b/game-app/game-core/src/main/java/tools/util/ToolArguments.java @@ -1,11 +1,13 @@ package tools.util; +import org.jetbrains.annotations.NonNls; + /** A collection of argument names common to all support tools. */ public final class ToolArguments { - public static final String MAP_FOLDER = "triplea.map.folder"; - public static final String UNIT_HEIGHT = "triplea.unit.height"; - public static final String UNIT_WIDTH = "triplea.unit.width"; - public static final String UNIT_ZOOM = "triplea.unit.zoom"; + @NonNls public static final String MAP_FOLDER = "triplea.map.folder"; + @NonNls public static final String UNIT_HEIGHT = "triplea.unit.height"; + @NonNls public static final String UNIT_WIDTH = "triplea.unit.width"; + @NonNls public static final String UNIT_ZOOM = "triplea.unit.zoom"; private ToolArguments() {} } diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/DefaultAttachmentTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/DefaultAttachmentTest.java index 363d38419b6..e1ec2cf4979 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/DefaultAttachmentTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/DefaultAttachmentTest.java @@ -9,6 +9,7 @@ import static org.mockito.Mockito.when; import javax.annotation.Nullable; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -19,8 +20,8 @@ final class DefaultAttachmentTest { @ExtendWith(MockitoExtension.class) @Nested final class EqualsTest { - private static final String NAME = "attachment"; - private static final String OTHER_NAME = "otherAttachment"; + @NonNls private static final String NAME = "attachment"; + @NonNls private static final String OTHER_NAME = "otherAttachment"; @Mock private Attachable attachable; @Mock private Attachable otherAttachable; diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/GameSequenceTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/GameSequenceTest.java index 5fde167902e..d30310de5ef 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/GameSequenceTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/GameSequenceTest.java @@ -7,14 +7,15 @@ import games.strategy.triplea.delegate.TestDelegate; import java.util.Properties; import javax.annotation.Nullable; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; final class GameSequenceTest { @Nested final class SetRoundAndStepTest { - private static final String GAME_STEP_NAME = "gameStep"; - private static final String OTHER_GAME_STEP_NAME = "otherGameStep"; + @NonNls private static final String GAME_STEP_NAME = "gameStep"; + @NonNls private static final String OTHER_GAME_STEP_NAME = "otherGameStep"; private final GameData gameData = new GameData(); private final GamePlayer player = new GamePlayer("player", gameData); diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameDataVariablesTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameDataVariablesTest.java index e75b30c48c1..a9e716bdd75 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameDataVariablesTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameDataVariablesTest.java @@ -14,6 +14,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.triplea.generic.xml.reader.XmlMapper; import org.triplea.map.data.elements.Game; @@ -21,11 +22,11 @@ class GameDataVariablesTest { - private static final String FOLDER = "src/test/resources/variable_parsing/"; - private static final String EMPTY_LIST = FOLDER + "empty_list.xml"; - private static final String SINGLE_ELEMENT_LIST = FOLDER + "single_element_list.xml"; - private static final String MANY_ELEMENT_LIST = FOLDER + "many_element_list.xml"; - private static final String NESTED_VARIABLE = FOLDER + "nested_variable.xml"; + @NonNls private static final String FOLDER = "src/test/resources/variable_parsing/"; + @NonNls private static final String EMPTY_LIST = FOLDER + "empty_list.xml"; + @NonNls private static final String SINGLE_ELEMENT_LIST = FOLDER + "single_element_list.xml"; + @NonNls private static final String MANY_ELEMENT_LIST = FOLDER + "many_element_list.xml"; + @NonNls private static final String NESTED_VARIABLE = FOLDER + "nested_variable.xml"; @Test void emptyList() throws Exception { diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/PropertyValueTypeInferenceTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/PropertyValueTypeInferenceTest.java index 4e239dac8fb..9401e079679 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/PropertyValueTypeInferenceTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/PropertyValueTypeInferenceTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; +import java.util.Locale; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -47,10 +48,12 @@ void inferNumberValues(final int value) { @ValueSource(booleans = {true, false}) void inferNumberValues(final boolean value) { assertThat( - PropertyValueTypeInference.castToInferredType(String.valueOf(value).toLowerCase()), + PropertyValueTypeInference.castToInferredType( + String.valueOf(value).toLowerCase(Locale.ROOT)), is(value)); assertThat( - PropertyValueTypeInference.castToInferredType(String.valueOf(value).toUpperCase()), + PropertyValueTypeInference.castToInferredType( + String.valueOf(value).toUpperCase(Locale.ROOT)), is(value)); } diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/properties/DoublePropertyTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/properties/DoublePropertyTest.java index a1ba45f8f69..5d049173d65 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/properties/DoublePropertyTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/properties/DoublePropertyTest.java @@ -4,14 +4,15 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; final class DoublePropertyTest { @Nested final class ConstructorTest { - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; + @NonNls private static final String NAME = "name"; + @NonNls private static final String DESCRIPTION = "description"; private static final double MAX_VALUE = 100.0; private static final double MIN_VALUE = 0.0; private static final double DEFAULT_VALUE = 42.0; diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/properties/MapPropertyTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/properties/MapPropertyTest.java index 32dfde75560..6aea50f9aa9 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/properties/MapPropertyTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/properties/MapPropertyTest.java @@ -6,14 +6,15 @@ import com.google.common.collect.ImmutableMap; import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; final class MapPropertyTest { @Nested final class ValidateTest { - private static final String KEY_1 = "key1"; - private static final String KEY_2 = "key2"; + @NonNls private static final String KEY_1 = "key1"; + @NonNls private static final String KEY_2 = "key2"; private final MapProperty mapProperty = newMapProperty(ImmutableMap.of(KEY_1, 42)); diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/AutoSaveFileUtilsTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/AutoSaveFileUtilsTest.java index 5f1327eb794..c801c37577d 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/AutoSaveFileUtilsTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/AutoSaveFileUtilsTest.java @@ -7,9 +7,11 @@ import games.strategy.triplea.settings.ClientSetting; import java.nio.file.Path; import java.time.LocalDateTime; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +@NonNls final class AutoSaveFileUtilsTest extends AbstractClientSettingTestCase { private final AutoSaveFileUtils autoSaveFileUtils = new AutoSaveFileUtils(); @@ -19,7 +21,7 @@ final class GetAutoSaveFileTest { void shouldReturnFileInAutoSaveFolder() { ClientSetting.saveGamesFolderPath.setValue(Path.of("path", "to", "saves")); - final String fileName = "savegame.tsvg"; + @NonNls final String fileName = "savegame.tsvg"; assertThat( autoSaveFileUtils.getAutoSaveFile(fileName), is(Path.of("path", "to", "saves", "autoSave", fileName))); @@ -28,7 +30,7 @@ void shouldReturnFileInAutoSaveFolder() { @Nested final class GetAutoSaveFileNameTest { - private static final String BASE_FILE_NAME = "baseFileName"; + @NonNls private static final String BASE_FILE_NAME = "baseFileName"; @Test void shouldNotPrefixFileNameWhenHeaded() { diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/I18nResourceBundleTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/I18nResourceBundleTest.java index 35ff78c5562..c19e67861b8 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/I18nResourceBundleTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/I18nResourceBundleTest.java @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test; class I18nResourceBundleTest { - private static final String resourcePath = "propertyTest"; + @NonNls private static final String resourcePath = "propertyTest"; private static final int maxTextMatchLengthWithEn = 10; @NonNls @@ -96,7 +96,7 @@ void ensureLocalizedResultOfGetText() { assert !enString.equals(langString) : errorTextNotTranslated(bundle, locale.toString(), key); } - assert 0 != langString.length() + assert !langString.isEmpty() : errorTextNotTranslated(bundle, locale.toString(), key); } catch (final MissingResourceException e) { assertNotNull(e); diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/ContentReaderTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/ContentReaderTest.java index 0a911cf9e01..2a5eb80cdd8 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/ContentReaderTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/ContentReaderTest.java @@ -8,6 +8,7 @@ import java.io.ByteArrayInputStream; import java.nio.file.Files; import java.nio.file.Path; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -19,7 +20,7 @@ @SuppressWarnings("InnerClassMayBeStatic") final class ContentReaderTest extends AbstractClientSettingTestCase { - private static final String URI = "some://uri"; + @NonNls private static final String URI = "some://uri"; @ExtendWith(MockitoExtension.class) @Nested diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/DownloadMapsWindowMapsListingTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/DownloadMapsWindowMapsListingTest.java index cecea52abbd..9d81fd120f1 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/DownloadMapsWindowMapsListingTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/map/download/DownloadMapsWindowMapsListingTest.java @@ -13,12 +13,13 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.triplea.http.client.maps.listing.MapDownloadItem; import org.triplea.map.description.file.MapDescriptionYaml; class DownloadMapsWindowMapsListingTest extends AbstractClientSettingTestCase { - private static final String MAP_NAME = "new_test_order"; + @NonNls private static final String MAP_NAME = "new_test_order"; private static final MapDownloadItem TEST_MAP = MapDownloadItem.builder() diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginIntegrationTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginIntegrationTest.java index 10c40b1df4e..b58079288a7 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginIntegrationTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginIntegrationTest.java @@ -11,6 +11,7 @@ import games.strategy.net.ILoginValidator; import games.strategy.net.IServerMessenger; import games.strategy.net.TestServerMessenger; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; @@ -19,8 +20,8 @@ import org.triplea.util.Version; final class ClientLoginIntegrationTest { - private static final String PASSWORD = "password"; - private static final String OTHER_PASSWORD = "otherPassword"; + @NonNls private static final String PASSWORD = "password"; + @NonNls private static final String OTHER_PASSWORD = "otherPassword"; private IServerMessenger serverMessenger; private int serverPort; diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginValidatorTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginValidatorTest.java index 0943ede4191..19abe6e9a54 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginValidatorTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/ClientLoginValidatorTest.java @@ -5,14 +5,15 @@ import games.strategy.engine.framework.startup.login.ClientLoginValidator.ErrorMessages; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; final class ClientLoginValidatorTest { - private static final String PASSWORD = "password"; - private static final String OTHER_PASSWORD = "otherPassword"; + @NonNls private static final String PASSWORD = "password"; + @NonNls private static final String OTHER_PASSWORD = "otherPassword"; @ExtendWith(MockitoExtension.class) @Nested diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/HmacSha512AuthenticatorTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/HmacSha512AuthenticatorTest.java index 19e50699a78..e7bf646781e 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/HmacSha512AuthenticatorTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/login/HmacSha512AuthenticatorTest.java @@ -19,11 +19,12 @@ import java.util.Base64; import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; final class HmacSha512AuthenticatorTest { - private static final String PASSWORD = "←PASSWORD↑WITH→UNICODE↓CHARS"; + @NonNls private static final String PASSWORD = "←PASSWORD↑WITH→UNICODE↓CHARS"; private static String newBase64String() { final byte[] bytes = new byte[8]; diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/mc/PlayerDisconnectActionTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/mc/PlayerDisconnectActionTest.java index ceaa55ed829..0d67f8be82a 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/mc/PlayerDisconnectActionTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/mc/PlayerDisconnectActionTest.java @@ -11,6 +11,7 @@ import games.strategy.net.Node; import java.net.InetSocketAddress; import java.util.Set; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -26,7 +27,7 @@ class PlayerDisconnectActionTest { private static final INode NODE_1 = new Node("node-1", InetSocketAddress.createUnresolved("99.99.99.100", 5000)); - private static final String NODE_2_NAME = "node-2"; + @NonNls private static final String NODE_2_NAME = "node-2"; private static final INode NODE_2 = new Node(NODE_2_NAME + " (2)", InetSocketAddress.createUnresolved("2.2.2.2", 8000)); diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcherTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcherTest.java index 657fc832a81..08fbb79e488 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcherTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/InGameLobbyWatcherTest.java @@ -19,6 +19,7 @@ import games.strategy.net.IServerMessenger; import java.net.InetAddress; import java.util.Optional; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Nested; @@ -133,10 +134,10 @@ public void testShutDown_gameIdNotNull() throws Exception { @Nested final class GetLobbySystemPropertyTest { - private static final String KEY = "__GetLobbySystemPropertyTest__key"; - private static final String BACKUP_KEY = KEY + ".backup"; - private static final String VALUE = "primaryValue"; - private static final String BACKUP_VALUE = "backupValue"; + @NonNls private static final String KEY = "__GetLobbySystemPropertyTest__key"; + @NonNls private static final String BACKUP_KEY = KEY + ".backup"; + @NonNls private static final String VALUE = "primaryValue"; + @NonNls private static final String BACKUP_VALUE = "backupValue"; @AfterEach void clearSystemProperties() { diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/LobbyWatcherKeepAliveTaskTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/LobbyWatcherKeepAliveTaskTest.java index 1c2dec8376e..e7250c8a4dc 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/LobbyWatcherKeepAliveTaskTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/LobbyWatcherKeepAliveTaskTest.java @@ -9,6 +9,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -18,9 +19,9 @@ @ExtendWith(MockitoExtension.class) class LobbyWatcherKeepAliveTaskTest { - private static final String ID_0 = "id0"; - private static final String ID_1 = "id1"; - private static final String ID_2 = "id2"; + @NonNls private static final String ID_0 = "id0"; + @NonNls private static final String ID_1 = "id1"; + @NonNls private static final String ID_2 = "id2"; @Mock private Consumer gameIdSetter; @Mock private Predicate keepAliveSender; @@ -54,7 +55,7 @@ void happyCase() { /** * Keep alive false means repost, so we should request id_1, if it keeps alive then we have - * re-established connecton and should update game id. + * re-established connection and should update game id. */ @Test void negativeKeepAliveReEstablishesConnection() { @@ -91,7 +92,7 @@ void negativeKeepAliveDoesNotReportSuccess() { * either, and we have to re-post again to get a second new ID.
* Run #1: id_0 does not keep alive, we get id_1, it fails keep alive
* -> do not report anything
- * Run #2: id_1 fails keep alive, repost for id_2, id_2 passes keep alive.
+ * Run #2: id_1 fails keep alive, re-post for id_2, id_2 passes keep alive.
* -> update game id to id_2 and report re-established */ @Test @@ -143,7 +144,7 @@ void connectionLostIsOnlyReportedOnce() { * Lose connection, then get a new ID, it is alive, should report re-established.
* Run #1: Id_0 fails
* -> connection lost reported
- * Run #2: Id 0 does not keep alive, repost for Id 1, id 1 keeps alive
+ * Run #2: Id_0 does not keep alive, repost for Id_1, id 1 keeps alive
* -> re-establish reported */ @Test @@ -183,9 +184,9 @@ void notAliveAndThenAliveWithSameId() { /** * Connection lost, then we get a 'false' keep-alive and re-post and get a new ID. The new ID does - * not 'keep-alive', we should not report re-established connecton.
+ * not 'keep-alive', we should not report re-established connection.
* Run #1: id0 fails
- * Run #2: id0 does not keep alive, we repost and get id1, id1 does not keep-alive
+ * Run #2: id0 does not keep alive, we re-post and get id1, id1 does not keep-alive
* -> should not report re-established */ @Test diff --git a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModelTest.java b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModelTest.java index deb202bacde..830f1c434ae 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModelTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorModelTest.java @@ -14,6 +14,7 @@ import games.strategy.engine.framework.startup.mc.ClientModel; import games.strategy.triplea.settings.AbstractClientSettingTestCase; import java.util.Observer; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -24,8 +25,8 @@ @ExtendWith(MockitoExtension.class) class GameSelectorModelTest extends AbstractClientSettingTestCase { - private static final String fakeGameRound = "3"; - private static final String fakeGameName = "_fakeGameName_"; + @NonNls private static final String fakeGameRound = "3"; + @NonNls private static final String fakeGameName = "_fakeGameName_"; private GameSelectorModel testObj; diff --git a/game-app/game-core/src/test/java/games/strategy/engine/random/PlainRandomSourceTest.java b/game-app/game-core/src/test/java/games/strategy/engine/random/PlainRandomSourceTest.java index 86d20451d67..978c18258aa 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/random/PlainRandomSourceTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/random/PlainRandomSourceTest.java @@ -10,10 +10,11 @@ import java.util.Arrays; import java.util.stream.IntStream; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; final class PlainRandomSourceTest { - private static final String ANNOTATION = "annotation"; + @NonNls private static final String ANNOTATION = "annotation"; private static final int MAX = 6; private final PlainRandomSource plainRandomSource = new PlainRandomSource(); diff --git a/game-app/game-core/src/test/java/games/strategy/net/NodeTest.java b/game-app/game-core/src/test/java/games/strategy/net/NodeTest.java index 2f6a95f133c..2172200f163 100644 --- a/game-app/game-core/src/test/java/games/strategy/net/NodeTest.java +++ b/game-app/game-core/src/test/java/games/strategy/net/NodeTest.java @@ -4,14 +4,15 @@ import static org.hamcrest.Matchers.is; import java.net.InetSocketAddress; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.triplea.java.IpAddressParser; class NodeTest { - private static final String NAME = "name"; - private static final String IP = "99.99.99.99"; + @NonNls private static final String NAME = "name"; + @NonNls private static final String IP = "99.99.99.99"; private static final int PORT = 3000; @Test diff --git a/game-app/game-core/src/test/java/games/strategy/net/TestServerMessenger.java b/game-app/game-core/src/test/java/games/strategy/net/TestServerMessenger.java index d0b2eefec15..7001ad1d7a1 100644 --- a/game-app/game-core/src/test/java/games/strategy/net/TestServerMessenger.java +++ b/game-app/game-core/src/test/java/games/strategy/net/TestServerMessenger.java @@ -1,11 +1,11 @@ package games.strategy.net; import java.io.IOException; +import org.jetbrains.annotations.NonNls; /** Implementation of {@link IServerMessenger} suitable for testing. */ public final class TestServerMessenger extends ServerMessenger { - public static final String ADMINISTRATIVE_MUTE_CHAT_MESSAGE = "You have been muted"; - public static final String CHAT_CHANNEL_NAME = "_TEST_CHAT"; + @NonNls public static final String CHAT_CHANNEL_NAME = "_TEST_CHAT"; public TestServerMessenger() throws IOException { super("server", 0, new DefaultObjectStreamFactory()); diff --git a/game-app/game-core/src/test/java/games/strategy/net/UserNameAssignerTest.java b/game-app/game-core/src/test/java/games/strategy/net/UserNameAssignerTest.java index 41a8a872cee..38de986519f 100644 --- a/game-app/game-core/src/test/java/games/strategy/net/UserNameAssignerTest.java +++ b/game-app/game-core/src/test/java/games/strategy/net/UserNameAssignerTest.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -13,10 +14,10 @@ @ExtendWith(MockitoExtension.class) class UserNameAssignerTest { - private static final String NAME_1 = "name_one"; - private static final String NAME_2 = "name_two"; + @NonNls private static final String NAME_1 = "name_one"; + @NonNls private static final String NAME_2 = "name_two"; - private static final String MAC = "mac 1"; + @NonNls private static final String MAC = "mac 1"; /** * Null for IP address or node list means we have something wrong on the server side and should diff --git a/game-app/game-core/src/test/java/games/strategy/net/nio/ForgotPasswordConversationTest.java b/game-app/game-core/src/test/java/games/strategy/net/nio/ForgotPasswordConversationTest.java index 36381287d01..d85e728f7c0 100644 --- a/game-app/game-core/src/test/java/games/strategy/net/nio/ForgotPasswordConversationTest.java +++ b/game-app/game-core/src/test/java/games/strategy/net/nio/ForgotPasswordConversationTest.java @@ -11,6 +11,7 @@ import games.strategy.net.TempPasswordHistory; import java.net.InetAddress; import java.util.function.Predicate; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -19,7 +20,7 @@ @ExtendWith(MockitoExtension.class) class ForgotPasswordConversationTest { - private static final String USERNAME = "username"; + @NonNls private static final String USERNAME = "username"; @Mock private Predicate forgotPasswordModule; @Mock private TempPasswordHistory tempPasswordHistory; diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/FiringGroupTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/FiringGroupTest.java index 1b7cc5398a8..0484d1bbdd2 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/FiringGroupTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/FiringGroupTest.java @@ -14,6 +14,7 @@ import games.strategy.triplea.attachments.UnitAttachment; import java.util.Comparator; import java.util.List; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -22,7 +23,7 @@ @ExtendWith(MockitoExtension.class) class FiringGroupTest { - private static final String GROUP_NAME = "test"; + @NonNls private static final String GROUP_NAME = "test"; final GameData gameData = givenGameData().build(); @Mock GamePlayer player; diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/ui/UnitIconPropertiesTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/ui/UnitIconPropertiesTest.java index 0fdcf838530..4d04e31e531 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/ui/UnitIconPropertiesTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/ui/UnitIconPropertiesTest.java @@ -19,18 +19,19 @@ import java.util.Properties; import javax.annotation.Nullable; import nl.jqno.equalsverifier.EqualsVerifier; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; final class UnitIconPropertiesTest { - private static final String CONDITION_1_NAME = "condition1Name"; - private static final String CONDITION_2_NAME = "condition2Name"; - private static final String GAME_NAME = "gameName"; - private static final String ICON_1_PATH = "path/to/icon_1.png"; - private static final String ICON_2_PATH = "path/to/icon_2.png"; - private static final String ICON_3_PATH = "path/to/icon_3.png"; - private static final String PLAYER_NAME = "playerName"; - private static final String UNIT_TYPE_NAME = "unitTypeName"; + @NonNls private static final String CONDITION_1_NAME = "condition1Name"; + @NonNls private static final String CONDITION_2_NAME = "condition2Name"; + @NonNls private static final String GAME_NAME = "gameName"; + @NonNls private static final String ICON_1_PATH = "path/to/icon_1.png"; + @NonNls private static final String ICON_2_PATH = "path/to/icon_2.png"; + @NonNls private static final String ICON_3_PATH = "path/to/icon_3.png"; + @NonNls private static final String PLAYER_NAME = "playerName"; + @NonNls private static final String UNIT_TYPE_NAME = "unitTypeName"; private static String formatIconId(final @Nullable String conditionName) { return formatIconId(GAME_NAME, PLAYER_NAME, UNIT_TYPE_NAME, conditionName); diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/ui/mapdata/IslandTerritoryFinderTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/ui/mapdata/IslandTerritoryFinderTest.java index 78e8873b9b4..3b9c54b6206 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/ui/mapdata/IslandTerritoryFinderTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/ui/mapdata/IslandTerritoryFinderTest.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -16,10 +17,10 @@ final class IslandTerritoryFinderTest { - private static final String SEA_TERR = ToolsUtil.TERRITORY_SEA_ZONE_INFIX; - private static final String SEA_TERR_1 = ToolsUtil.TERRITORY_SEA_ZONE_INFIX + " 1"; - private static final String LAND_TERR = "Land"; - private static final String LAND_TERR_1 = "Land 1"; + @NonNls private static final String SEA_TERR = ToolsUtil.TERRITORY_SEA_ZONE_INFIX; + @NonNls private static final String SEA_TERR_1 = ToolsUtil.TERRITORY_SEA_ZONE_INFIX + " 1"; + @NonNls private static final String LAND_TERR = "Land"; + @NonNls private static final String LAND_TERR_1 = "Land 1"; private final Polygon inner = new Polygon(); private final Polygon adjacentInner = new Polygon(); diff --git a/game-app/game-core/src/test/java/org/triplea/config/AbstractInputStreamPropertyReaderTest.java b/game-app/game-core/src/test/java/org/triplea/config/AbstractInputStreamPropertyReaderTest.java index c1aa8b7679e..f5ab2741f3c 100644 --- a/game-app/game-core/src/test/java/org/triplea/config/AbstractInputStreamPropertyReaderTest.java +++ b/game-app/game-core/src/test/java/org/triplea/config/AbstractInputStreamPropertyReaderTest.java @@ -11,6 +11,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.triplea.java.function.ThrowingSupplier; @@ -18,7 +19,7 @@ final class AbstractInputStreamPropertyReaderTest { @Nested final class ReadPropertyInternalTest { - private static final String PROPERTY_SOURCE_NAME = "propertySourceName"; + @NonNls private static final String PROPERTY_SOURCE_NAME = "propertySourceName"; private AbstractInputStreamPropertyReader newAbstractInputStreamPropertyReader( final ThrowingSupplier inputStreamSupplier) { diff --git a/game-app/game-core/src/test/java/org/triplea/config/AbstractPropertyReaderTestCase.java b/game-app/game-core/src/test/java/org/triplea/config/AbstractPropertyReaderTestCase.java index cf2dfabda2d..dafdf4e3b3c 100644 --- a/game-app/game-core/src/test/java/org/triplea/config/AbstractPropertyReaderTestCase.java +++ b/game-app/game-core/src/test/java/org/triplea/config/AbstractPropertyReaderTestCase.java @@ -6,14 +6,15 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; /** A fixture for testing the basic aspects of classes that implement {@link PropertyReader}. */ public abstract class AbstractPropertyReaderTestCase { - private static final String ABSENT_PROPERTY_KEY = "absentKey"; - private static final String PRESENT_PROPERTY_KEY = "presentKey"; + @NonNls private static final String ABSENT_PROPERTY_KEY = "absentKey"; + @NonNls private static final String PRESENT_PROPERTY_KEY = "presentKey"; protected AbstractPropertyReaderTestCase() {} @@ -39,7 +40,7 @@ private PropertyReader newSingletonPropertyReader(final String value) throws Exc /** Test cases for {@link PropertyReader#readProperty(String)}. */ @Nested public final class ReadPropertyTest { - private static final String PRESENT_PROPERTY_VALUE = "presentValue"; + @NonNls private static final String PRESENT_PROPERTY_VALUE = "presentValue"; private PropertyReader propertyReader; diff --git a/game-app/game-core/src/test/java/org/triplea/debug/error/reporting/formatting/ErrorReportBodyFormatterTest.java b/game-app/game-core/src/test/java/org/triplea/debug/error/reporting/formatting/ErrorReportBodyFormatterTest.java index 3dfc7f0eb0f..8a65517dd0d 100644 --- a/game-app/game-core/src/test/java/org/triplea/debug/error/reporting/formatting/ErrorReportBodyFormatterTest.java +++ b/game-app/game-core/src/test/java/org/triplea/debug/error/reporting/formatting/ErrorReportBodyFormatterTest.java @@ -8,6 +8,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -18,7 +19,7 @@ @ExtendWith(MockitoExtension.class) class ErrorReportBodyFormatterTest { - private static final String SAMPLE_USER_DESCRIPTION = "Pol, a bene vortex"; + @NonNls private static final String SAMPLE_USER_DESCRIPTION = "Pol, a bene vortex"; private static final String LOG_MESSAGE = "LogMessage, Golly gosh, yer not drinking me without a desolation!"; private static final Exception EXCEPTION_WITH_MESSAGE = diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/framework/ProcessRunnerUtil.java b/game-app/game-headed/src/main/java/games/strategy/engine/framework/ProcessRunnerUtil.java index 8ba77e2f78f..023951000d6 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/framework/ProcessRunnerUtil.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/framework/ProcessRunnerUtil.java @@ -8,9 +8,11 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Optional; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; /** To hold various static utility methods for running a java program. */ @Slf4j @@ -18,7 +20,7 @@ class ProcessRunnerUtil { public static List createBasicJavaArgs() { - List commands = new ArrayList<>(); + @NonNls List commands = new ArrayList<>(); String javaCommand = Path.of(SystemProperties.getJavaHome(), "bin", "java").toString(); commands.add(javaCommand); @@ -27,13 +29,13 @@ public static List createBasicJavaArgs() { Optional maxMemory = ManagementFactory.getRuntimeMXBean().getInputArguments().stream() - .filter(s -> s.toLowerCase().startsWith("-xmx")) + .filter(s -> s.toLowerCase(Locale.ROOT).startsWith("-xmx")) .map(s -> s.substring(4)) .findFirst(); maxMemory.ifPresent(max -> commands.add("-Xmx" + max)); Optional maxStackSize = ManagementFactory.getRuntimeMXBean().getInputArguments().stream() - .filter(s -> s.toLowerCase().startsWith("-xss")) + .filter(s -> s.toLowerCase(Locale.ROOT).startsWith("-xss")) .findFirst(); maxStackSize.ifPresent(commands::add); if (SystemProperties.isMac()) { diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/CommentPanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/CommentPanel.java index 5098c4ab10b..2b765765bae 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/CommentPanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/CommentPanel.java @@ -36,6 +36,7 @@ import javax.swing.text.StyleConstants; import javax.swing.tree.TreeNode; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.java.ThreadRunner; import org.triplea.swing.SwingAction; @@ -161,7 +162,7 @@ private void readHistoryTreeEvent(final TreeModelEvent e) { try { // insert into ui document final Document doc = text.getDocument(); - final String prefix = " " + player + "(" + round + ") : "; + @NonNls final String prefix = " " + player + "(" + round + ") : "; text.insertIcon(icon); doc.insertString(doc.getLength(), prefix, bold); doc.insertString(doc.getLength(), m.group(1) + "\n", normal); @@ -201,7 +202,7 @@ private void loadHistory() { final String title = node.getTitle(); final Matcher m = p.matcher(title); if (m.matches()) { - final String prefix = " " + player + "(" + round + ") : "; + @NonNls final String prefix = " " + player + "(" + round + ") : "; final Icon lastIcon = icon; SwingUtilities.invokeLater( () -> { diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/export/ScreenshotExporter.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/export/ScreenshotExporter.java index a4674a766da..713363f8a4d 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/export/ScreenshotExporter.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/export/ScreenshotExporter.java @@ -17,6 +17,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Path; +import java.util.Locale; import java.util.Optional; import java.util.concurrent.CompletableFuture; import javax.imageio.ImageIO; @@ -60,7 +61,7 @@ private Optional promptSaveFile() { .parent(frame) .title("Export Screenshot") .fileExtension("png") - .filenameFilter((dir, name) -> name.toLowerCase().endsWith(".png")) + .filenameFilter((dir, name) -> name.toLowerCase(Locale.ROOT).endsWith(".png")) .build() .chooseFile(); } @@ -69,7 +70,7 @@ private void runSave(final GameData gameData, final HistoryNode node, final Path final CompletableFuture future = SwingComponents.runWithProgressBar( frame, - "Saving picture of the gameboard...", + "Saving picture of the game board...", () -> { save(gameData, node, file); return null; @@ -82,13 +83,13 @@ private void runSave(final GameData gameData, final HistoryNode node, final Path JOptionPane.showMessageDialog( frame, "Saved to: " + file.toAbsolutePath(), - "Gameboard Picture Saved", + "Game Board Picture Saved", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( frame, e.getMessage(), - "Error Saving Gameboard Picture", + "Error Saving Game Board Picture", JOptionPane.ERROR_MESSAGE); } })); diff --git a/game-app/game-headed/src/test/java/games/strategy/engine/lobby/client/ui/LobbyGameTableModelTest.java b/game-app/game-headed/src/test/java/games/strategy/engine/lobby/client/ui/LobbyGameTableModelTest.java index b03493d997c..4375eb4bbb7 100644 --- a/game-app/game-headed/src/test/java/games/strategy/engine/lobby/client/ui/LobbyGameTableModelTest.java +++ b/game-app/game-headed/src/test/java/games/strategy/engine/lobby/client/ui/LobbyGameTableModelTest.java @@ -10,6 +10,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.time.Instant; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -28,8 +29,8 @@ @Execution(ExecutionMode.SAME_THREAD) final class LobbyGameTableModelTest { - private static final String id0 = "id0"; - private static final String id1 = "id1"; + @NonNls private static final String id0 = "id0"; + @NonNls private static final String id1 = "id1"; private static final GameDescription gameDescription0; private static final GameDescription gameDescription1; diff --git a/game-app/map-data/src/main/java/org/triplea/map/data/elements/PropertyList.java b/game-app/map-data/src/main/java/org/triplea/map/data/elements/PropertyList.java index 4c7e3cb8091..c0f197ebf4b 100644 --- a/game-app/map-data/src/main/java/org/triplea/map/data/elements/PropertyList.java +++ b/game-app/map-data/src/main/java/org/triplea/map/data/elements/PropertyList.java @@ -8,12 +8,14 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.jetbrains.annotations.NonNls; import org.triplea.generic.xml.reader.annotations.Attribute; import org.triplea.generic.xml.reader.annotations.BodyText; import org.triplea.generic.xml.reader.annotations.LegacyXml; import org.triplea.generic.xml.reader.annotations.Tag; import org.triplea.generic.xml.reader.annotations.TagList; +@NonNls @Getter @Builder @NoArgsConstructor diff --git a/game-app/map-data/src/main/java/org/triplea/map/description/file/MapDescriptionYaml.java b/game-app/map-data/src/main/java/org/triplea/map/description/file/MapDescriptionYaml.java index dc59526f7d4..23c9722384c 100644 --- a/game-app/map-data/src/main/java/org/triplea/map/description/file/MapDescriptionYaml.java +++ b/game-app/map-data/src/main/java/org/triplea/map/description/file/MapDescriptionYaml.java @@ -17,6 +17,7 @@ import lombok.Singular; import lombok.ToString; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.io.FileUtils; /** @@ -41,7 +42,7 @@ @EqualsAndHashCode public class MapDescriptionYaml { - public static final String MAP_YAML_FILE_NAME = "map.yml"; + @NonNls public static final String MAP_YAML_FILE_NAME = "map.yml"; private static final int MAX_GAME_NAME_LENGTH = 70; private static final int MAX_MAP_NAME_LENGTH = 70; diff --git a/game-app/smoke-testing/src/test/java/games/strategy/engine/data/ParseGameXmlsTest.java b/game-app/smoke-testing/src/test/java/games/strategy/engine/data/ParseGameXmlsTest.java index 824040ff68e..660329ba186 100644 --- a/game-app/smoke-testing/src/test/java/games/strategy/engine/data/ParseGameXmlsTest.java +++ b/game-app/smoke-testing/src/test/java/games/strategy/engine/data/ParseGameXmlsTest.java @@ -9,6 +9,7 @@ import java.nio.file.Path; import java.util.Collection; import java.util.Comparator; +import java.util.Locale; import java.util.Optional; import java.util.stream.Collectors; import org.junit.jupiter.params.ParameterizedTest; @@ -29,7 +30,8 @@ void parseGameFiles(final Path xmlFile) { @SuppressWarnings("unused") static Collection parseGameFiles() throws IOException { return TestDataFileLister.listFilesInTestResourcesDirectory("map-xmls").stream() - .sorted(Comparator.comparing(file -> file.getFileName().toString().toUpperCase())) + .sorted( + Comparator.comparing(file -> file.getFileName().toString().toUpperCase(Locale.ROOT))) .collect(Collectors.toList()); } } diff --git a/game-app/smoke-testing/src/test/java/games/strategy/engine/data/TestDataFileLister.java b/game-app/smoke-testing/src/test/java/games/strategy/engine/data/TestDataFileLister.java index 6be51e677c0..42709bb4381 100644 --- a/game-app/smoke-testing/src/test/java/games/strategy/engine/data/TestDataFileLister.java +++ b/game-app/smoke-testing/src/test/java/games/strategy/engine/data/TestDataFileLister.java @@ -7,6 +7,7 @@ import java.util.Comparator; import java.util.stream.Collectors; import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NonNls; import org.triplea.java.Postconditions; @UtilityClass @@ -18,7 +19,8 @@ class TestDataFileLister { * @param folderName Name of the folder in 'test/resources' * @return List of all files located in specified folder. */ - Collection listFilesInTestResourcesDirectory(final String folderName) throws IOException { + Collection listFilesInTestResourcesDirectory(final @NonNls String folderName) + throws IOException { return Files.list(findFilesInFolder(folderName)) .sorted(Comparator.comparing(Path::getFileName, Comparator.comparing(Path::toString))) .collect(Collectors.toList()); diff --git a/lib/feign-common/src/main/java/org/triplea/http/client/HttpConstants.java b/lib/feign-common/src/main/java/org/triplea/http/client/HttpConstants.java index 568a02a8b6b..b22097d26b9 100644 --- a/lib/feign-common/src/main/java/org/triplea/http/client/HttpConstants.java +++ b/lib/feign-common/src/main/java/org/triplea/http/client/HttpConstants.java @@ -2,10 +2,11 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.jetbrains.annotations.NonNls; /** Utility class with constants for HTTP clients. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class HttpConstants { - public static final String ACCEPT_JSON = "Accept: application/json"; - public static final String CONTENT_TYPE_JSON = "Content-Type: application/json"; + @NonNls public static final String ACCEPT_JSON = "Accept: application/json"; + @NonNls public static final String CONTENT_TYPE_JSON = "Content-Type: application/json"; } diff --git a/lib/feign-common/src/test/java/org/triplea/http/client/JsonDecoderTest.java b/lib/feign-common/src/test/java/org/triplea/http/client/JsonDecoderTest.java index abfee44a81f..c205b08ddca 100644 --- a/lib/feign-common/src/test/java/org/triplea/http/client/JsonDecoderTest.java +++ b/lib/feign-common/src/test/java/org/triplea/http/client/JsonDecoderTest.java @@ -9,11 +9,12 @@ import java.time.Month; import java.time.ZoneOffset; import lombok.AllArgsConstructor; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; class JsonDecoderTest { // Thu Jun 06 2019 04:20:06Z - private static final String JSON_STRING = "{\"instant\":1559794806.329342000}"; + @NonNls private static final String JSON_STRING = "{\"instant\":1559794806.329342000}"; @AllArgsConstructor private static class InstantExample { diff --git a/lib/java-extras/src/main/java/games/strategy/engine/framework/system/SystemProperties.java b/lib/java-extras/src/main/java/games/strategy/engine/framework/system/SystemProperties.java index d209a5ec1df..5443605fc5e 100644 --- a/lib/java-extras/src/main/java/games/strategy/engine/framework/system/SystemProperties.java +++ b/lib/java-extras/src/main/java/games/strategy/engine/framework/system/SystemProperties.java @@ -2,6 +2,7 @@ import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Locale; import java.util.Properties; /** @@ -48,11 +49,11 @@ public static String getUserName() { } public static boolean isMac() { - return getOperatingSystem().toLowerCase().contains("mac"); + return getOperatingSystem().toLowerCase(Locale.ROOT).contains("mac"); } public static boolean isWindows() { - return getOperatingSystem().toLowerCase().contains("windows"); + return getOperatingSystem().toLowerCase(Locale.ROOT).contains("windows"); } public static void setJavaNetUseSystemProxies(final String value) { diff --git a/lib/java-extras/src/main/java/org/triplea/java/Sha512Hasher.java b/lib/java-extras/src/main/java/org/triplea/java/Sha512Hasher.java index 1368f5649b8..35a259e2f9d 100644 --- a/lib/java-extras/src/main/java/org/triplea/java/Sha512Hasher.java +++ b/lib/java-extras/src/main/java/org/triplea/java/Sha512Hasher.java @@ -6,8 +6,10 @@ import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Locale; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.jetbrains.annotations.NonNls; /** * A class which implements the TripleA-Lobby-Login authentication system using RSA encryption for @@ -15,11 +17,11 @@ */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class Sha512Hasher { - private static final String PSEUDO_SALT = "TripleA"; - private static final String SHA_512 = "SHA-512"; + @NonNls private static final String PSEUDO_SALT = "TripleA"; + @NonNls private static final String SHA_512 = "SHA-512"; /** - * Creates a SHA-512 hash of a given String with a salt.
+ * Creates an SHA-512 hash of a given String with a salt.
* The server doesn't need to know the actual password, so this hash essentially replaces the real * password. In case any other server authentication system SHA-512 hashes passwords before * sending them, we are applying a 'TripleA' prefix to the given String before hashing. This way @@ -37,13 +39,13 @@ public static String hashPasswordWithSalt(final String password) { return sha512(PSEUDO_SALT + password); } - /** Creates a SHA-512 hash of the given String. */ + /** Creates an SHA-512 hash of the given String. */ @VisibleForTesting static String sha512(final String input) { try { return BaseEncoding.base16() .encode(MessageDigest.getInstance(SHA_512).digest(input.getBytes(StandardCharsets.UTF_8))) - .toLowerCase(); + .toLowerCase(Locale.ROOT); } catch (final NoSuchAlgorithmException e) { throw new IllegalStateException(SHA_512 + " is not supported!", e); } diff --git a/lib/java-extras/src/main/java/org/triplea/java/StringUtils.java b/lib/java-extras/src/main/java/org/triplea/java/StringUtils.java index 2fcc107bb8b..f2f162e0552 100644 --- a/lib/java-extras/src/main/java/org/triplea/java/StringUtils.java +++ b/lib/java-extras/src/main/java/org/triplea/java/StringUtils.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.util.Locale; import lombok.experimental.UtilityClass; /** A collection of useful methods for working with instances of {@link String}. */ @@ -23,7 +24,9 @@ public final class StringUtils { public static String capitalize(final String value) { checkNotNull(value); - return value.isEmpty() ? value : (value.substring(0, 1).toUpperCase() + value.substring(1)); + return value.isEmpty() + ? value + : (value.substring(0, 1).toUpperCase(Locale.ENGLISH) + value.substring(1)); } /** diff --git a/lib/java-extras/src/test/java/org/triplea/java/cache/ttl/ExpiringAfterWriteTtlCacheTest.java b/lib/java-extras/src/test/java/org/triplea/java/cache/ttl/ExpiringAfterWriteTtlCacheTest.java index 10baccf0602..8bfdbd0d63b 100644 --- a/lib/java-extras/src/test/java/org/triplea/java/cache/ttl/ExpiringAfterWriteTtlCacheTest.java +++ b/lib/java-extras/src/test/java/org/triplea/java/cache/ttl/ExpiringAfterWriteTtlCacheTest.java @@ -10,6 +10,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -17,7 +18,7 @@ class ExpiringAfterWriteTtlCacheTest { - private static final String KEY = "key-value"; + @NonNls private static final String KEY = "key-value"; private static final int VALUE = 100; private ExpiringAfterWriteTtlCache realCache; diff --git a/lib/swing-lib/src/main/java/org/triplea/swing/AutoCompletion.java b/lib/swing-lib/src/main/java/org/triplea/swing/AutoCompletion.java index bd35dd21a0c..8d4e699e544 100644 --- a/lib/swing-lib/src/main/java/org/triplea/swing/AutoCompletion.java +++ b/lib/swing-lib/src/main/java/org/triplea/swing/AutoCompletion.java @@ -8,6 +8,7 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.text.Normalizer; +import java.util.Locale; import javax.swing.ComboBoxEditor; import javax.swing.ComboBoxModel; import javax.swing.JComboBox; @@ -220,6 +221,8 @@ static boolean startsWith(final String str1, final String str2) { } private static String normalize(final String str) { - return Normalizer.normalize(str, Normalizer.Form.NFD).replaceAll("\\p{M}", "").toUpperCase(); + return Normalizer.normalize(str, Normalizer.Form.NFD) + .replaceAll("\\p{M}", "") + .toUpperCase(Locale.ROOT); } } diff --git a/lib/swing-lib/src/main/java/org/triplea/swing/FileChooser.java b/lib/swing-lib/src/main/java/org/triplea/swing/FileChooser.java index d407b3e0074..3229ea426bd 100644 --- a/lib/swing-lib/src/main/java/org/triplea/swing/FileChooser.java +++ b/lib/swing-lib/src/main/java/org/triplea/swing/FileChooser.java @@ -6,14 +6,16 @@ import java.io.FilenameFilter; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Locale; import java.util.Optional; import javax.annotation.Nullable; import javax.swing.JOptionPane; import lombok.Builder; +import org.jetbrains.annotations.NonNls; @Builder public class FileChooser { - private static final String PERIOD = "."; + @NonNls private static final String PERIOD = "."; @Nullable private Frame parent; @Nullable private String title; @@ -81,8 +83,8 @@ public static Path appendExtensionIfAbsent(final Path file, final String extensi final String extensionWithLeadingPeriod = extensionWithLeadingPeriod(extension); if (file.getFileName() .toString() - .toLowerCase() - .endsWith(extensionWithLeadingPeriod.toLowerCase())) { + .toLowerCase(Locale.ROOT) + .endsWith(extensionWithLeadingPeriod.toLowerCase(Locale.ROOT))) { return file; } diff --git a/lib/swing-lib/src/main/java/org/triplea/swing/JTableTypeAheadListener.java b/lib/swing-lib/src/main/java/org/triplea/swing/JTableTypeAheadListener.java index 7891b96c0a1..7e9e9917a19 100644 --- a/lib/swing-lib/src/main/java/org/triplea/swing/JTableTypeAheadListener.java +++ b/lib/swing-lib/src/main/java/org/triplea/swing/JTableTypeAheadListener.java @@ -2,8 +2,10 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.util.Locale; import javax.swing.JTable; import lombok.RequiredArgsConstructor; +import org.jetbrains.annotations.NonNls; /** A KeyListener that implements row selection in a JTable by prefix-matching typed text. */ @RequiredArgsConstructor @@ -14,7 +16,7 @@ public class JTableTypeAheadListener extends KeyAdapter { // Column that contains text data that should be matched. private final int columnIndex; - private String inputString = ""; + @NonNls String inputString = ""; private long keyPressTime; @Override @@ -36,8 +38,8 @@ public void keyPressed(KeyEvent evt) { final int selectedRow = table.getSelectedRow(); for (int i = 0; i < rowCount; i++) { int row = (selectedRow + i) % rowCount; - String str = "" + tableModel.getValueAt(row, columnIndex); - if (str.toLowerCase().startsWith(inputString)) { + @NonNls String str = "" + tableModel.getValueAt(row, columnIndex); + if (str.toLowerCase(Locale.ROOT).startsWith(inputString)) { selectRow(row); break; } diff --git a/lib/swing-lib/src/test/java/org/triplea/swing/JCheckBoxBuilderTest.java b/lib/swing-lib/src/test/java/org/triplea/swing/JCheckBoxBuilderTest.java index 9261b3ba113..7a570048be3 100644 --- a/lib/swing-lib/src/test/java/org/triplea/swing/JCheckBoxBuilderTest.java +++ b/lib/swing-lib/src/test/java/org/triplea/swing/JCheckBoxBuilderTest.java @@ -8,6 +8,7 @@ import java.util.function.Consumer; import javax.swing.JCheckBox; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -17,7 +18,7 @@ @ExtendWith(MockitoExtension.class) class JCheckBoxBuilderTest { - private static final String TITLE = "title-text"; + @NonNls private static final String TITLE = "title-text"; @Mock private SettingPersistence settingPersistence; @Mock private Consumer actionListener; diff --git a/lib/swing-lib/src/test/java/org/triplea/swing/JFrameBuilderTest.java b/lib/swing-lib/src/test/java/org/triplea/swing/JFrameBuilderTest.java index fe771e7261e..24276ae8500 100644 --- a/lib/swing-lib/src/test/java/org/triplea/swing/JFrameBuilderTest.java +++ b/lib/swing-lib/src/test/java/org/triplea/swing/JFrameBuilderTest.java @@ -11,6 +11,7 @@ import java.awt.Point; import javax.swing.JFrame; import javax.swing.JLabel; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -21,7 +22,7 @@ @ExtendWith(DisabledInHeadlessGraphicsEnvironment.class) @ExtendWith(MockitoExtension.class) class JFrameBuilderTest { - private static final String TITLE = "A falsis, finis secundus quadra."; + @NonNls private static final String TITLE = "A falsis, finis secundus quadra."; private static final int WIDTH = 100; private static final int HEIGHT = 1000; diff --git a/lib/swing-lib/src/test/java/org/triplea/swing/JMenuBuilderTest.java b/lib/swing-lib/src/test/java/org/triplea/swing/JMenuBuilderTest.java index a23ca0549f9..7eba98561a1 100644 --- a/lib/swing-lib/src/test/java/org/triplea/swing/JMenuBuilderTest.java +++ b/lib/swing-lib/src/test/java/org/triplea/swing/JMenuBuilderTest.java @@ -6,8 +6,10 @@ import java.awt.event.KeyEvent; import javax.swing.JMenu; import javax.swing.JMenuItem; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; +@NonNls class JMenuBuilderTest { private static final String TITLE = "title"; diff --git a/lib/swing-lib/src/test/java/org/triplea/swing/JMenuItemCheckBoxBuilderTest.java b/lib/swing-lib/src/test/java/org/triplea/swing/JMenuItemCheckBoxBuilderTest.java index 95f8665ef94..73beb1f001d 100644 --- a/lib/swing-lib/src/test/java/org/triplea/swing/JMenuItemCheckBoxBuilderTest.java +++ b/lib/swing-lib/src/test/java/org/triplea/swing/JMenuItemCheckBoxBuilderTest.java @@ -6,6 +6,7 @@ import java.awt.event.KeyEvent; import java.util.function.Consumer; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -13,7 +14,7 @@ import org.mockito.junit.jupiter.MockitoExtension; class JMenuItemCheckBoxBuilderTest { - private static final String TITLE = "title"; + @NonNls private static final String TITLE = "title"; @Test void verifyTitle() { diff --git a/lib/test-common/src/main/java/org/triplea/test/common/security/TestSecurityUtils.java b/lib/test-common/src/main/java/org/triplea/test/common/security/TestSecurityUtils.java index afaa9de2f51..43a0ba3f705 100644 --- a/lib/test-common/src/main/java/org/triplea/test/common/security/TestSecurityUtils.java +++ b/lib/test-common/src/main/java/org/triplea/test/common/security/TestSecurityUtils.java @@ -12,10 +12,11 @@ import java.security.PublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; +import org.jetbrains.annotations.NonNls; /** A collection of useful methods for writing tests that involve security functions. */ public final class TestSecurityUtils { - private static final String RSA_ALGORITHM = "RSA"; + @NonNls private static final String RSA_ALGORITHM = "RSA"; private TestSecurityUtils() {} diff --git a/lib/test-common/src/test/java/org/triplea/test/common/TestDataFileReaderTest.java b/lib/test-common/src/test/java/org/triplea/test/common/TestDataFileReaderTest.java index 26b355a407a..fb97467d69d 100644 --- a/lib/test-common/src/test/java/org/triplea/test/common/TestDataFileReaderTest.java +++ b/lib/test-common/src/test/java/org/triplea/test/common/TestDataFileReaderTest.java @@ -5,10 +5,11 @@ import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.jupiter.api.Assertions.assertThrows; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; class TestDataFileReaderTest { - private static final String SAMPLE_FILE_PATH = "example/example_file.txt"; + @NonNls private static final String SAMPLE_FILE_PATH = "example/example_file.txt"; private static final String EXPECTED_CONTENT = "A file with some example text" + System.lineSeparator() diff --git a/lib/test-common/src/test/java/org/triplea/test/common/swing/SwingComponentWrapperTest.java b/lib/test-common/src/test/java/org/triplea/test/common/swing/SwingComponentWrapperTest.java index 6ffe7128c83..3b7bdb23031 100644 --- a/lib/test-common/src/test/java/org/triplea/test/common/swing/SwingComponentWrapperTest.java +++ b/lib/test-common/src/test/java/org/triplea/test/common/swing/SwingComponentWrapperTest.java @@ -3,12 +3,13 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; class SwingComponentWrapperTest { - private static final String CHILD_NAME = "child_name"; + @NonNls private static final String CHILD_NAME = "child_name"; @Test void findChildByName() { diff --git a/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/WebsocketPaths.java b/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/WebsocketPaths.java index 089b9505569..25c9cae23df 100644 --- a/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/WebsocketPaths.java +++ b/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/WebsocketPaths.java @@ -1,9 +1,10 @@ package org.triplea.http.client.web.socket; import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NonNls; @UtilityClass public class WebsocketPaths { - public static final String GAME_CONNECTIONS = "/game-connection/ws"; - public static final String PLAYER_CONNECTIONS = "/player-connection/ws"; + @NonNls public static final String GAME_CONNECTIONS = "/game-connection/ws"; + @NonNls public static final String PLAYER_CONNECTIONS = "/player-connection/ws"; } diff --git a/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/GenericWebSocketClientTest.java b/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/GenericWebSocketClientTest.java index d7be1c813dc..2052a8f4c08 100644 --- a/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/GenericWebSocketClientTest.java +++ b/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/GenericWebSocketClientTest.java @@ -6,6 +6,7 @@ import com.google.gson.Gson; import java.net.URI; import java.util.function.Consumer; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -13,6 +14,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +@NonNls @SuppressWarnings("InnerClassMayBeStatic") @ExtendWith(MockitoExtension.class) class GenericWebSocketClientTest { diff --git a/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/WebSocketConnectionTest.java b/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/WebSocketConnectionTest.java index 7e659d67cc4..91dbc03c065 100644 --- a/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/WebSocketConnectionTest.java +++ b/lib/websocket-client/src/test/java/org/triplea/http/client/web/socket/WebSocketConnectionTest.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -28,6 +29,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +@NonNls @SuppressWarnings("InnerClassMayBeStatic") class WebSocketConnectionTest { private static final URI INVALID_URI = URI.create("wss://server.invalid"); diff --git a/lib/websocket-server/src/main/java/org/triplea/web/socket/InetExtractor.java b/lib/websocket-server/src/main/java/org/triplea/web/socket/InetExtractor.java index 72d49cce396..dabc3864a44 100644 --- a/lib/websocket-server/src/main/java/org/triplea/web/socket/InetExtractor.java +++ b/lib/websocket-server/src/main/java/org/triplea/web/socket/InetExtractor.java @@ -6,11 +6,12 @@ import java.net.UnknownHostException; import java.util.Map; import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NonNls; @UtilityClass public class InetExtractor { - @VisibleForTesting + @VisibleForTesting @NonNls public static final String IP_ADDRESS_KEY = "javax.websocket.endpoint.remoteAddress"; /** diff --git a/lib/websocket-server/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java b/lib/websocket-server/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java index 82252db290b..cbeb7903ca3 100644 --- a/lib/websocket-server/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java +++ b/lib/websocket-server/src/main/java/org/triplea/web/socket/WebSocketMessagingBus.java @@ -14,6 +14,7 @@ import lombok.AllArgsConstructor; import lombok.Value; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NonNls; import org.triplea.http.client.web.socket.MessageEnvelope; import org.triplea.http.client.web.socket.messages.MessageType; import org.triplea.http.client.web.socket.messages.WebSocketMessage; @@ -22,7 +23,7 @@ @AllArgsConstructor(access = AccessLevel.PACKAGE, onConstructor_ = @VisibleForTesting) @Slf4j public class WebSocketMessagingBus { - public static final String MESSAGING_BUS_KEY = "messaging.bus"; + @NonNls public static final String MESSAGING_BUS_KEY = "messaging.bus"; @Nonnull private final MessageBroadcaster messageBroadcaster; @Nonnull private final MessageSender messageSender; @@ -78,7 +79,7 @@ public void addMessageListener( * Adds a listener that will be invoked when any message is received * * @param messageListener The message listener to be added, will be invoked with any message - * recieved. + * received. */ public void addMessageListener(final Consumer messageListener) { anyMessageListeners.add(messageListener); @@ -115,11 +116,12 @@ private Optional> determineMatchingMessageType(final MessageEnvel } private static Predicate> matchListenersWithMessageTypeId( - final String messageTypeId) { + @NonNls final String messageTypeId) { return messageListener -> messageListener.messageType.getMessageTypeId().equals(messageTypeId); } - private Stream> getListenersForMessageTypeId(final String messageTypeId) { + private Stream> getListenersForMessageTypeId( + @NonNls final String messageTypeId) { return messageListeners.stream() .filter( messageListener -> @@ -141,7 +143,7 @@ void onOpen(final WebSocketSession session) { } void onError(final WebSocketSession session, final Throwable throwable) { - final String errorId = UUID.randomUUID().toString(); + @NonNls final String errorId = UUID.randomUUID().toString(); log.error( "Error-id processing websocket message, returning an error message to user. " + "Error id: {}", diff --git a/lib/websocket-server/src/test/java/org/triplea/web/socket/InetExtractorTest.java b/lib/websocket-server/src/test/java/org/triplea/web/socket/InetExtractorTest.java index d0930b7228e..0b7a5ed3886 100644 --- a/lib/websocket-server/src/test/java/org/triplea/web/socket/InetExtractorTest.java +++ b/lib/websocket-server/src/test/java/org/triplea/web/socket/InetExtractorTest.java @@ -5,11 +5,12 @@ import java.net.InetAddress; import java.util.Map; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; class InetExtractorTest { - private static final String IP_ADDRESS = "127.0.0.1"; + @NonNls private static final String IP_ADDRESS = "127.0.0.1"; @Test void verify() throws Exception { diff --git a/lib/websocket-server/src/test/java/org/triplea/web/socket/MessageSenderTest.java b/lib/websocket-server/src/test/java/org/triplea/web/socket/MessageSenderTest.java index 2ef25ba8c45..e84d1ea528e 100644 --- a/lib/websocket-server/src/test/java/org/triplea/web/socket/MessageSenderTest.java +++ b/lib/websocket-server/src/test/java/org/triplea/web/socket/MessageSenderTest.java @@ -8,6 +8,7 @@ import com.google.gson.Gson; import lombok.AllArgsConstructor; +import org.jetbrains.annotations.NonNls; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -22,7 +23,7 @@ class MessageSenderTest { private static final MessageEnvelope MESSAGE_ENVELOPE = new StringMessage("message!").toEnvelope(); - private static final String SERVER_MESSAGE_JSON = new Gson().toJson(MESSAGE_ENVELOPE); + @NonNls private static final String SERVER_MESSAGE_JSON = new Gson().toJson(MESSAGE_ENVELOPE); @Mock private WebSocketSession session; diff --git a/lib/xml-reader/src/main/java/org/triplea/generic/xml/reader/XmlParser.java b/lib/xml-reader/src/main/java/org/triplea/generic/xml/reader/XmlParser.java index 8a9d4e91573..2b6ef40e8e8 100644 --- a/lib/xml-reader/src/main/java/org/triplea/generic/xml/reader/XmlParser.java +++ b/lib/xml-reader/src/main/java/org/triplea/generic/xml/reader/XmlParser.java @@ -1,9 +1,11 @@ package org.triplea.generic.xml.reader; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.function.Consumer; import javax.xml.stream.XMLStreamReader; +import org.jetbrains.annotations.NonNls; import org.triplea.java.function.ThrowingRunnable; class XmlParser { @@ -11,12 +13,12 @@ class XmlParser { private final Map> childTagHandlers = new HashMap<>(); private Consumer bodyHandler; - XmlParser(final String tagName) { - this.tagName = tagName.toUpperCase(); + XmlParser(final @NonNls String tagName) { + this.tagName = tagName.toUpperCase(Locale.ENGLISH); } - void childTagHandler(final String childTagName, final ThrowingRunnable tagHandler) { - childTagHandlers.put(childTagName.toUpperCase(), tagHandler); + void childTagHandler(final @NonNls String childTagName, final ThrowingRunnable tagHandler) { + childTagHandlers.put(childTagName.toUpperCase(Locale.ENGLISH), tagHandler); } void bodyHandler(final Consumer bodyHandler) { @@ -29,7 +31,7 @@ void parse(final XMLStreamReader streamReader) throws Throwable { final int event = streamReader.next(); switch (event) { case XMLStreamReader.START_ELEMENT: - final String childTag = streamReader.getLocalName().toUpperCase(); + final String childTag = streamReader.getLocalName().toUpperCase(Locale.ENGLISH); final ThrowingRunnable childTagHandler = childTagHandlers.get(childTag); if (childTagHandler != null) { childTagHandler.run(); diff --git a/lib/xml-reader/src/main/java/org/triplea/generic/xml/scanner/AttributeScanner.java b/lib/xml-reader/src/main/java/org/triplea/generic/xml/scanner/AttributeScanner.java index b8bd66adf84..a0bd12d3fdf 100644 --- a/lib/xml-reader/src/main/java/org/triplea/generic/xml/scanner/AttributeScanner.java +++ b/lib/xml-reader/src/main/java/org/triplea/generic/xml/scanner/AttributeScanner.java @@ -1,5 +1,6 @@ package org.triplea.generic.xml.scanner; +import java.util.Locale; import java.util.Optional; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -18,7 +19,7 @@ Optional scanForAttributeValue( while (streamReader.hasNext()) { final int event = streamReader.next(); if (event == XMLStreamReader.START_ELEMENT) { - final String tag = streamReader.getLocalName().toUpperCase(); + final String tag = streamReader.getLocalName().toUpperCase(Locale.ENGLISH); if (tag.equalsIgnoreCase(parameters.getTag())) { final String attributeValue =