Skip to content

Commit 44f5bb2

Browse files
committed
TerritoryIdentity: Convert class to record
This should help with Jackson serialization/deserialization.
1 parent ae117b2 commit 44f5bb2

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
// gradlew publishToSonatype closeSonatypeStagingRepository for staging and manual release
1010
// gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository for automatic release
1111

12-
val versionObject = Version(breaking = "1", minor = "0", nonbreaking = "0", revision = "1", date = "2206")
12+
val versionObject = Version(breaking = "1", minor = "0", nonbreaking = "0", revision = "2", date = "2206")
1313
project.group = "com.riskrieg"
1414
project.version = "$versionObject"
1515

src/main/java/com/riskrieg/map/territory/TerritoryIdentity.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99

1010
import java.util.Objects;
1111

12-
public final class TerritoryIdentity {
12+
public record TerritoryIdentity(String rawValue) {
1313

14-
private final String value;
15-
16-
public TerritoryIdentity(String value) {
17-
Objects.requireNonNull(value);
18-
if (value.isBlank()) {
19-
throw new IllegalStateException("String 'value' cannot be blank");
14+
public TerritoryIdentity {
15+
Objects.requireNonNull(rawValue);
16+
if (rawValue.isBlank()) {
17+
throw new IllegalStateException("String 'rawValue' cannot be blank");
2018
}
21-
this.value = value;
2219
}
2320

2421
@Override
@@ -30,17 +27,17 @@ public boolean equals(Object obj) {
3027
return false;
3128
}
3229
var that = (TerritoryIdentity) obj;
33-
return Objects.equals(this.value, that.value);
30+
return Objects.equals(this.rawValue, that.rawValue);
3431
}
3532

3633
@Override
3734
public int hashCode() {
38-
return Objects.hash(value);
35+
return Objects.hash(rawValue);
3936
}
4037

4138
@Override
4239
public String toString() {
43-
return value;
40+
return rawValue;
4441
}
4542

4643

0 commit comments

Comments
 (0)