Skip to content

Commit

Permalink
Player: Remove option for country to be null.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjon3377 committed Jan 12, 2024
1 parent be7f513 commit 3740745
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ public void applyInPlace(final @NotNull IMutableMap map) throws ChangesetFailure
final @NotNull String name1 = matchingOld.getName();
final @Nullable String country1 = matchingOld.country();
final @NotNull String portrait1 = matchingOld.portrait();
final Player matchingOldCopy = new PlayerImpl(playerId1, name1, Objects.requireNonNullElse(country1, ""), false,
portrait1);
final Player matchingOldCopy = new PlayerImpl(playerId1, name1, country1, false, portrait1);
final int playerId = matchingNew.playerId();
final @NotNull String name = matchingNew.getName();
final @Nullable String country = matchingNew.country();
final @NotNull String portrait = matchingNew.portrait();
final Player matchingNewCopy = new PlayerImpl(playerId, name, Objects.requireNonNullElse(country, ""), true,
portrait);
final Player matchingNewCopy = new PlayerImpl(playerId, name, country, true, portrait);
// TODO: try-catch here, in case the first operation fails?
map.replacePlayer(matchingOld, matchingOldCopy);
map.replacePlayer(matchingNew, matchingNewCopy);
Expand Down
4 changes: 2 additions & 2 deletions model/src/main/java/common/map/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ default String getPortrait() {
}

/**
* The country the player is associated with. TODO: Should this be required to be unique in a map?
* The country the player is associated with. The empty string if not provided. TODO: Should this be required to be
* unique in a map?
*/
@Nullable
String country();
}

0 comments on commit 3740745

Please sign in to comment.