From 57a9b336738a9ce551a5869ed3cf14f86ce41b0c Mon Sep 17 00:00:00 2001 From: Exlll Date: Sat, 9 Jul 2022 21:33:14 +0200 Subject: [PATCH] Add UUID serializer --- README.md | 6 +- .../exlll/configlib/SerializerSelector.java | 4 +- .../java/de/exlll/configlib/Serializers.java | 12 ++++ .../configlib/ExampleConfigurationTests.java | 12 ++++ .../configlib/SerializerSelectorTest.java | 7 +++ .../de/exlll/configlib/SerializersTest.java | 15 +++++ .../ExampleConfigurationA1.java | 55 +++++++++++++++++++ .../ExampleConfigurationA2.java | 55 +++++++++++++++++++ .../ExampleConfigurationsSerialized.java | 12 ++++ .../configurations/ExampleInitializer.java | 33 +++++++++++ 10 files changed, 209 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 853c371..a837bae 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ the [Tutorial](https://github.com/Exlll/ConfigLib/wiki/Tutorial) page on the wik * Automatic creation, saving, loading, and updating of configuration files * Support for comments through annotations * Support for all primitive types, their wrapper types, and Strings -* Support for `BigInteger`, `BigDecimal`, `LocalDate`, `LocalTime`, and `LocalDateTime` +* Support for `BigInteger`, `BigDecimal`, `LocalDate`, `LocalTime`, `LocalDateTime`, and `UUID` * Support for (nested) lists, sets, arrays, and maps * Support for enums and POJOs (+ inheritance!) * Support for Bukkit's `ConfigurationSerializable` types (e.g. `ItemStack`) @@ -155,6 +155,7 @@ A configuration type may only contain fields of the following types: | Characters and strings | `char`, `Character`, `String` | | Big numeric types | `BigInteger`, `BigDecimal` | | Time related types | `LocalTime`, `LocalDate`, `LocalDateTime` | +| Utility types | `UUID` | | Enums | Any Java enum | | Configurations | Any configuration type | | `ConfigurationSerializable` | All Bukkit classes that implement this interface, like `ItemStack` | @@ -172,6 +173,8 @@ public final class SupportedTypes { boolean supported; Character supported; String supported; + LocalTime supported; + UUID supported; ExampleEnum supported; // where 'ExampleEnum' is some Java enum type ExampleConf supported; // where 'ExampleConf' is another configuration type @@ -439,6 +442,7 @@ library knows how to handle). The conversion happens according to the following | Characters and strings | `String` | | Big numeric types | `String` | | Time related types | `String` | +| Utility types | `String` | | Enums | `String` | | Configurations | `Map` | | `Set` | `List`* | diff --git a/configlib-core/src/main/java/de/exlll/configlib/SerializerSelector.java b/configlib-core/src/main/java/de/exlll/configlib/SerializerSelector.java index edfeb93..459c4db 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/SerializerSelector.java +++ b/configlib-core/src/main/java/de/exlll/configlib/SerializerSelector.java @@ -9,6 +9,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Map; +import java.util.UUID; final class SerializerSelector { private static final Map, Serializer> DEFAULT_SERIALIZERS = Map.ofEntries( @@ -33,7 +34,8 @@ final class SerializerSelector { Map.entry(BigDecimal.class, new BigDecimalSerializer()), Map.entry(LocalDate.class, new LocalDateSerializer()), Map.entry(LocalTime.class, new LocalTimeSerializer()), - Map.entry(LocalDateTime.class, new LocalDateTimeSerializer()) + Map.entry(LocalDateTime.class, new LocalDateTimeSerializer()), + Map.entry(UUID.class, new UuidSerializer()) ); private final ConfigurationProperties properties; diff --git a/configlib-core/src/main/java/de/exlll/configlib/Serializers.java b/configlib-core/src/main/java/de/exlll/configlib/Serializers.java index 2eb9e61..ff3a506 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/Serializers.java +++ b/configlib-core/src/main/java/de/exlll/configlib/Serializers.java @@ -241,6 +241,18 @@ final class Serializers { } } + static final class UuidSerializer implements Serializer { + @Override + public String serialize(UUID element) { + return element.toString(); + } + + @Override + public UUID deserialize(String element) { + return UUID.fromString(element); + } + } + static final class EnumSerializer implements Serializer, String> { private final Class> cls; diff --git a/configlib-core/src/test/java/de/exlll/configlib/ExampleConfigurationTests.java b/configlib-core/src/test/java/de/exlll/configlib/ExampleConfigurationTests.java index ac67fe3..e443701 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/ExampleConfigurationTests.java +++ b/configlib-core/src/test/java/de/exlll/configlib/ExampleConfigurationTests.java @@ -272,6 +272,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_localDate(), is(a1_2.getA1_localDate())); assertThat(a1_1.getA1_localTime(), is(a1_2.getA1_localTime())); assertThat(a1_1.getA1_localDateTime(), is(a1_2.getA1_localDateTime())); + assertThat(a1_1.getA1_uuid(), is(a1_2.getA1_uuid())); assertThat(a1_1.getA1_Enm(), is(a1_2.getA1_Enm())); assertThat(a1_1.getA1_b1(), is(a1_2.getA1_b1())); assertThat(a1_1.getA1_b2(), is(a1_2.getA1_b2())); @@ -289,6 +290,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_listLocalDate(), is(a1_2.getA1_listLocalDate())); assertThat(a1_1.getA1_listLocalTime(), is(a1_2.getA1_listLocalTime())); assertThat(a1_1.getA1_listLocalDateTime(), is(a1_2.getA1_listLocalDateTime())); + assertThat(a1_1.getA1_listUuid(), is(a1_2.getA1_listUuid())); assertThat(a1_1.getA1_listEnm(), is(a1_2.getA1_listEnm())); assertThat(a1_1.getA1_listB1(), is(a1_2.getA1_listB1())); assertThat(a1_1.getA1_listB2(), is(a1_2.getA1_listB2())); @@ -314,6 +316,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_arrayLocalDate(), is(a1_2.getA1_arrayLocalDate())); assertThat(a1_1.getA1_arrayLocalTime(), is(a1_2.getA1_arrayLocalTime())); assertThat(a1_1.getA1_arrayLocalDateTime(), is(a1_2.getA1_arrayLocalDateTime())); + assertThat(a1_1.getA1_arrayUuid(), is(a1_2.getA1_arrayUuid())); assertThat(a1_1.getA1_arrayEnm(), is(a1_2.getA1_arrayEnm())); assertThat(a1_1.getA1_arrayB1(), is(a1_2.getA1_arrayB1())); assertThat(a1_1.getA1_arrayB2(), is(a1_2.getA1_arrayB2())); @@ -331,6 +334,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_setLocalDate(), is(a1_2.getA1_setLocalDate())); assertThat(a1_1.getA1_setLocalTime(), is(a1_2.getA1_setLocalTime())); assertThat(a1_1.getA1_setLocalDateTime(), is(a1_2.getA1_setLocalDateTime())); + assertThat(a1_1.getA1_setUuid(), is(a1_2.getA1_setUuid())); assertThat(a1_1.getA1_setEnm(), is(a1_2.getA1_setEnm())); assertThat(a1_1.getA1_setB1(), is(a1_2.getA1_setB1())); assertThat(a1_1.getA1_setB2(), is(a1_2.getA1_setB2())); @@ -348,6 +352,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_mapLocalDateLocalDate(), is(a1_2.getA1_mapLocalDateLocalDate())); assertThat(a1_1.getA1_mapLocalTimeLocalTime(), is(a1_2.getA1_mapLocalTimeLocalTime())); assertThat(a1_1.getA1_mapLocalDateTimeLocalDateTime(), is(a1_2.getA1_mapLocalDateTimeLocalDateTime())); + assertThat(a1_1.getA1_mapUuidUuid(), is(a1_2.getA1_mapUuidUuid())); assertThat(a1_1.getA1_mapEnmEnm(), is(a1_2.getA1_mapEnmEnm())); assertThat(a1_1.getA1_mapIntegerB1(), is(a1_2.getA1_mapIntegerB1())); assertThat(a1_1.getA1_mapEnmB2(), is(a1_2.getA1_mapEnmB2())); @@ -391,6 +396,7 @@ class ExampleConfigurationTests { assertThat(a1_1.getA1_arrayArrayLocalDate(), is(a1_2.getA1_arrayArrayLocalDate())); assertThat(a1_1.getA1_arrayArrayLocalTime(), is(a1_2.getA1_arrayArrayLocalTime())); assertThat(a1_1.getA1_arrayArrayLocalDateTime(), is(a1_2.getA1_arrayArrayLocalDateTime())); + assertThat(a1_1.getA1_arrayArrayUuid(), is(a1_2.getA1_arrayArrayUuid())); assertThat(a1_1.getA1_arrayArrayEnm(), is(a1_2.getA1_arrayArrayEnm())); assertThat(a1_1.getA1_arrayArrayB1(), is(a1_2.getA1_arrayArrayB1())); assertThat(a1_1.getA1_arrayArrayB2(), is(a1_2.getA1_arrayArrayB2())); @@ -437,6 +443,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_localDate(), is(a2_2.getA2_localDate())); assertThat(a2_1.getA2_localTime(), is(a2_2.getA2_localTime())); assertThat(a2_1.getA2_localDateTime(), is(a2_2.getA2_localDateTime())); + assertThat(a2_1.getA2_uuid(), is(a2_2.getA2_uuid())); assertThat(a2_1.getA2_Enm(), is(a2_2.getA2_Enm())); assertThat(a2_1.getA2_b1(), is(a2_2.getA2_b1())); assertThat(a2_1.getA2_b2(), is(a2_2.getA2_b2())); @@ -454,6 +461,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_listLocalDate(), is(a2_2.getA2_listLocalDate())); assertThat(a2_1.getA2_listLocalTime(), is(a2_2.getA2_listLocalTime())); assertThat(a2_1.getA2_listLocalDateTime(), is(a2_2.getA2_listLocalDateTime())); + assertThat(a2_1.getA2_listUuid(), is(a2_2.getA2_listUuid())); assertThat(a2_1.getA2_listEnm(), is(a2_2.getA2_listEnm())); assertThat(a2_1.getA2_listB1(), is(a2_2.getA2_listB1())); assertThat(a2_1.getA2_listB2(), is(a2_2.getA2_listB2())); @@ -479,6 +487,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_arrayLocalDate(), is(a2_2.getA2_arrayLocalDate())); assertThat(a2_1.getA2_arrayLocalTime(), is(a2_2.getA2_arrayLocalTime())); assertThat(a2_1.getA2_arrayLocalDateTime(), is(a2_2.getA2_arrayLocalDateTime())); + assertThat(a2_1.getA2_arrayUuid(), is(a2_2.getA2_arrayUuid())); assertThat(a2_1.getA2_arrayEnm(), is(a2_2.getA2_arrayEnm())); assertThat(a2_1.getA2_arrayB1(), is(a2_2.getA2_arrayB1())); assertThat(a2_1.getA2_arrayB2(), is(a2_2.getA2_arrayB2())); @@ -496,6 +505,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_setLocalDate(), is(a2_2.getA2_setLocalDate())); assertThat(a2_1.getA2_setLocalTime(), is(a2_2.getA2_setLocalTime())); assertThat(a2_1.getA2_setLocalDateTime(), is(a2_2.getA2_setLocalDateTime())); + assertThat(a2_1.getA2_setUuid(), is(a2_2.getA2_setUuid())); assertThat(a2_1.getA2_setEnm(), is(a2_2.getA2_setEnm())); assertThat(a2_1.getA2_setB1(), is(a2_2.getA2_setB1())); assertThat(a2_1.getA2_setB2(), is(a2_2.getA2_setB2())); @@ -513,6 +523,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_mapLocalDateLocalDate(), is(a2_2.getA2_mapLocalDateLocalDate())); assertThat(a2_1.getA2_mapLocalTimeLocalTime(), is(a2_2.getA2_mapLocalTimeLocalTime())); assertThat(a2_1.getA2_mapLocalDateTimeLocalDateTime(), is(a2_2.getA2_mapLocalDateTimeLocalDateTime())); + assertThat(a2_1.getA2_mapUuidUuid(), is(a2_2.getA2_mapUuidUuid())); assertThat(a2_1.getA2_mapEnmEnm(), is(a2_2.getA2_mapEnmEnm())); assertThat(a2_1.getA2_mapIntegerB1(), is(a2_2.getA2_mapIntegerB1())); assertThat(a2_1.getA2_mapEnmB2(), is(a2_2.getA2_mapEnmB2())); @@ -556,6 +567,7 @@ class ExampleConfigurationTests { assertThat(a2_1.getA2_arrayArrayLocalDate(), is(a2_2.getA2_arrayArrayLocalDate())); assertThat(a2_1.getA2_arrayArrayLocalTime(), is(a2_2.getA2_arrayArrayLocalTime())); assertThat(a2_1.getA2_arrayArrayLocalDateTime(), is(a2_2.getA2_arrayArrayLocalDateTime())); + assertThat(a2_1.getA2_arrayArrayUuid(), is(a2_2.getA2_arrayArrayUuid())); assertThat(a2_1.getA2_arrayArrayEnm(), is(a2_2.getA2_arrayArrayEnm())); assertThat(a2_1.getA2_arrayArrayB1(), is(a2_2.getA2_arrayArrayB1())); assertThat(a2_1.getA2_arrayArrayB2(), is(a2_2.getA2_arrayArrayB2())); diff --git a/configlib-core/src/test/java/de/exlll/configlib/SerializerSelectorTest.java b/configlib-core/src/test/java/de/exlll/configlib/SerializerSelectorTest.java index 3da377d..3568063 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/SerializerSelectorTest.java +++ b/configlib-core/src/test/java/de/exlll/configlib/SerializerSelectorTest.java @@ -17,6 +17,7 @@ import java.time.LocalTime; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import static de.exlll.configlib.TestUtils.*; import static org.hamcrest.MatcherAssert.assertThat; @@ -93,6 +94,12 @@ class SerializerSelectorTest { assertThat(serializer, instanceOf(LocalDateTimeSerializer.class)); } + @Test + void selectSerializerUuid() { + Serializer serializer = SELECTOR.select(UUID.class); + assertThat(serializer, instanceOf(UuidSerializer.class)); + } + @Test void selectSerializerEnum() { enum E {} diff --git a/configlib-core/src/test/java/de/exlll/configlib/SerializersTest.java b/configlib-core/src/test/java/de/exlll/configlib/SerializersTest.java index 6146758..efdcc21 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/SerializersTest.java +++ b/configlib-core/src/test/java/de/exlll/configlib/SerializersTest.java @@ -19,6 +19,7 @@ import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import static de.exlll.configlib.TestUtils.*; import static java.util.Arrays.asList; @@ -428,6 +429,20 @@ class SerializersTest { assertThat(serializer.deserialize("2000-02-29T10:11:12"), is(dateTime)); } + @Test + void uuidSerializer() { + Serializer serializer = new Serializers.UuidSerializer(); + + var uuid = UUID.randomUUID(); + var uuidString = uuid.toString(); + + assertThat(serializer.serialize(uuid), is(uuidString)); + + var deserialized = serializer.deserialize(uuidString); + + assertThat(uuid, is(deserialized)); + } + enum E {X, Y, Z} @ParameterizedTest diff --git a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA1.java b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA1.java index 27caa98..f0f618b 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA1.java +++ b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA1.java @@ -12,6 +12,7 @@ import java.time.LocalTime; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; @SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"}) @Configuration @@ -55,6 +56,7 @@ public class ExampleConfigurationA1 { private LocalDate a1_localDate; private LocalTime a1_localTime; private LocalDateTime a1_localDateTime; + private UUID a1_uuid; private ExampleEnum a1_Enm; /* OTHER CONFIGURATIONS */ @@ -76,6 +78,7 @@ public class ExampleConfigurationA1 { private List a1_listLocalDate; private List a1_listLocalTime; private List a1_listLocalDateTime; + private List a1_listUuid; private List a1_listEnm; private List a1_listB1; private List a1_listB2; @@ -103,6 +106,7 @@ public class ExampleConfigurationA1 { private LocalDate[] a1_arrayLocalDate; private LocalTime[] a1_arrayLocalTime; private LocalDateTime[] a1_arrayLocalDateTime; + private UUID[] a1_arrayUuid; private ExampleEnum[] a1_arrayEnm; private ExampleConfigurationB1[] a1_arrayB1; private ExampleConfigurationB2[] a1_arrayB2; @@ -122,6 +126,7 @@ public class ExampleConfigurationA1 { private Set a1_setLocalDate; private Set a1_setLocalTime; private Set a1_setLocalDateTime; + private Set a1_setUuid; private Set a1_setEnm; private Set a1_setB1; private Set a1_setB2; @@ -141,6 +146,7 @@ public class ExampleConfigurationA1 { private Map a1_mapLocalDateLocalDate; private Map a1_mapLocalTimeLocalTime; private Map a1_mapLocalDateTimeLocalDateTime; + private Map a1_mapUuidUuid; private Map a1_mapEnmEnm; private Map a1_mapIntegerB1; @@ -193,6 +199,7 @@ public class ExampleConfigurationA1 { private LocalDate[][] a1_arrayArrayLocalDate; private LocalTime[][] a1_arrayArrayLocalTime; private LocalDateTime[][] a1_arrayArrayLocalDateTime; + private UUID[][] a1_arrayArrayUuid; private ExampleEnum[][] a1_arrayArrayEnm; private ExampleConfigurationB1[][] a1_arrayArrayB1; private ExampleConfigurationB2[][] a1_arrayArrayB2; @@ -1415,4 +1422,52 @@ public class ExampleConfigurationA1 { public void setA1_mapEnmListPoint(Map> a1_mapEnmListPoint) { this.a1_mapEnmListPoint = a1_mapEnmListPoint; } + + public UUID getA1_uuid() { + return a1_uuid; + } + + public void setA1_uuid(UUID a1_uuid) { + this.a1_uuid = a1_uuid; + } + + public List getA1_listUuid() { + return a1_listUuid; + } + + public void setA1_listUuid(List a1_listUuid) { + this.a1_listUuid = a1_listUuid; + } + + public UUID[] getA1_arrayUuid() { + return a1_arrayUuid; + } + + public void setA1_arrayUuid(UUID[] a1_arrayUuid) { + this.a1_arrayUuid = a1_arrayUuid; + } + + public Set getA1_setUuid() { + return a1_setUuid; + } + + public void setA1_setUuid(Set a1_setUuid) { + this.a1_setUuid = a1_setUuid; + } + + public Map getA1_mapUuidUuid() { + return a1_mapUuidUuid; + } + + public void setA1_mapUuidUuid(Map a1_mapUuidUuid) { + this.a1_mapUuidUuid = a1_mapUuidUuid; + } + + public UUID[][] getA1_arrayArrayUuid() { + return a1_arrayArrayUuid; + } + + public void setA1_arrayArrayUuid(UUID[][] a1_arrayArrayUuid) { + this.a1_arrayArrayUuid = a1_arrayArrayUuid; + } } diff --git a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA2.java b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA2.java index 86db4c4..d0ccd48 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA2.java +++ b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationA2.java @@ -11,6 +11,7 @@ import java.time.LocalTime; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; @SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"}) public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { @@ -53,6 +54,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private LocalDate a2_localDate; private LocalTime a2_localTime; private LocalDateTime a2_localDateTime; + private UUID a2_uuid; private ExampleEnum a2_Enm; /* OTHER CONFIGURATIONS */ @@ -74,6 +76,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private List a2_listLocalDate; private List a2_listLocalTime; private List a2_listLocalDateTime; + private List a2_listUuid; private List a2_listEnm; private List a2_listB1; private List a2_listB2; @@ -101,6 +104,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private LocalDate[] a2_arrayLocalDate; private LocalTime[] a2_arrayLocalTime; private LocalDateTime[] a2_arrayLocalDateTime; + private UUID[] a2_arrayUuid; private ExampleEnum[] a2_arrayEnm; private ExampleConfigurationB1[] a2_arrayB1; private ExampleConfigurationB2[] a2_arrayB2; @@ -120,6 +124,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private Set a2_setLocalDate; private Set a2_setLocalTime; private Set a2_setLocalDateTime; + private Set a2_setUuid; private Set a2_setEnm; private Set a2_setB1; private Set a2_setB2; @@ -139,6 +144,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private Map a2_mapLocalDateLocalDate; private Map a2_mapLocalTimeLocalTime; private Map a2_mapLocalDateTimeLocalDateTime; + private Map a2_mapUuidUuid; private Map a2_mapEnmEnm; private Map a2_mapIntegerB1; @@ -191,6 +197,7 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { private LocalDate[][] a2_arrayArrayLocalDate; private LocalTime[][] a2_arrayArrayLocalTime; private LocalDateTime[][] a2_arrayArrayLocalDateTime; + private UUID[][] a2_arrayArrayUuid; private ExampleEnum[][] a2_arrayArrayEnm; private ExampleConfigurationB1[][] a2_arrayArrayB1; private ExampleConfigurationB2[][] a2_arrayArrayB2; @@ -1447,4 +1454,52 @@ public final class ExampleConfigurationA2 extends ExampleConfigurationA1 { public void setA2_mapEnmListPoint(Map> a2_mapEnmListPoint) { this.a2_mapEnmListPoint = a2_mapEnmListPoint; } + + public UUID getA2_uuid() { + return a2_uuid; + } + + public void setA2_uuid(UUID a2_uuid) { + this.a2_uuid = a2_uuid; + } + + public List getA2_listUuid() { + return a2_listUuid; + } + + public void setA2_listUuid(List a2_listUuid) { + this.a2_listUuid = a2_listUuid; + } + + public UUID[] getA2_arrayUuid() { + return a2_arrayUuid; + } + + public void setA2_arrayUuid(UUID[] a2_arrayUuid) { + this.a2_arrayUuid = a2_arrayUuid; + } + + public Set getA2_setUuid() { + return a2_setUuid; + } + + public void setA2_setUuid(Set a2_setUuid) { + this.a2_setUuid = a2_setUuid; + } + + public Map getA2_mapUuidUuid() { + return a2_mapUuidUuid; + } + + public void setA2_mapUuidUuid(Map a2_mapUuidUuid) { + this.a2_mapUuidUuid = a2_mapUuidUuid; + } + + public UUID[][] getA2_arrayArrayUuid() { + return a2_arrayArrayUuid; + } + + public void setA2_arrayArrayUuid(UUID[][] a2_arrayArrayUuid) { + this.a2_arrayArrayUuid = a2_arrayArrayUuid; + } } diff --git a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationsSerialized.java b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationsSerialized.java index e3e1ca4..80d1939 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationsSerialized.java +++ b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleConfigurationsSerialized.java @@ -93,6 +93,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_localDate", "2000-01-01"), entry("a1_localTime", "00:01"), entry("a1_localDateTime", "2000-01-01T00:00"), + entry("a1_uuid", "d50f3bdd-ac66-4b74-a01f-4617b24d68c0"), entry("a1_Enm", "A"), entry("a1_b1", EXAMPLE_CONFIGURATION_B1_1), entry("a1_b2", EXAMPLE_CONFIGURATION_B2_1), @@ -110,6 +111,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_listLocalDate", List.of("2000-01-01", "2000-01-02", "2000-01-03")), entry("a1_listLocalTime", List.of("00:01", "00:02", "00:03")), entry("a1_listLocalDateTime", List.of("2000-01-01T00:00", "2000-01-02T00:00", "2000-01-03T00:00")), + entry("a1_listUuid", List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2")), entry("a1_listEnm", List.of("A", "B", "C")), entry("a1_listB1", List.of(EXAMPLE_CONFIGURATION_B1_1)), entry("a1_listB2", List.of(EXAMPLE_CONFIGURATION_B2_1)), @@ -135,6 +137,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_arrayLocalDate", List.of("2000-01-01", "2000-01-02", "2000-01-03")), entry("a1_arrayLocalTime", List.of("00:01", "00:02", "00:03")), entry("a1_arrayLocalDateTime", List.of("2000-01-01T00:00", "2000-01-02T00:00", "2000-01-03T00:00")), + entry("a1_arrayUuid", List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2")), entry("a1_arrayEnm", List.of("A", "B", "C")), entry("a1_arrayB1", List.of(EXAMPLE_CONFIGURATION_B1_1)), entry("a1_arrayB2", List.of(EXAMPLE_CONFIGURATION_B2_1)), @@ -152,6 +155,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_setLocalDate", asList("2000-01-01", "2000-01-02", "2000-01-03")), entry("a1_setLocalTime", asList("00:01", "00:02", "00:03")), entry("a1_setLocalDateTime", asList("2000-01-01T00:00", "2000-01-02T00:00", "2000-01-03T00:00")), + entry("a1_setUuid", asList("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2")), entry("a1_setEnm", asList("A", "B", "C")), entry("a1_setB1", List.of(EXAMPLE_CONFIGURATION_B1_1)), entry("a1_setB2", List.of(EXAMPLE_CONFIGURATION_B2_1)), @@ -169,6 +173,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_mapLocalDateLocalDate", asMap("2000-01-01", "2000-01-02", "2000-01-03", "2000-01-04")), entry("a1_mapLocalTimeLocalTime", asMap("00:01", "00:02", "00:03", "00:04")), entry("a1_mapLocalDateTimeLocalDateTime", asMap("2000-01-01T00:00", "2000-01-02T00:00", "2000-01-03T00:00", "2000-01-04T00:00")), + entry("a1_mapUuidUuid", asMap("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2", "d50f3bdd-ac66-4b74-a01f-4617b24d68c3")), entry("a1_mapEnmEnm", asMap("A", "B", "C", "D")), entry("a1_mapIntegerB1", asMap(1L, EXAMPLE_CONFIGURATION_B1_1, 2L, EXAMPLE_CONFIGURATION_B1_2)), entry("a1_mapEnmB2", asMap("A", EXAMPLE_CONFIGURATION_B2_1, "B", EXAMPLE_CONFIGURATION_B2_2)), @@ -211,6 +216,7 @@ public final class ExampleConfigurationsSerialized { entry("a1_arrayArrayLocalDate", List.of(List.of(), List.of("2000-01-01"), List.of("2000-01-01", "2000-01-02"))), entry("a1_arrayArrayLocalTime", List.of(List.of(), List.of("00:01"), List.of("00:01", "00:02"))), entry("a1_arrayArrayLocalDateTime", List.of(List.of(), List.of("2000-01-01T00:00"), List.of("2000-01-01T00:00", "2000-01-02T00:00"))), + entry("a1_arrayArrayUuid", List.of(List.of(), List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0"), List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1"))), entry("a1_arrayArrayEnm", List.of(List.of(), List.of("A"), List.of("A", "B"))), entry("a1_arrayArrayB1", List.of(List.of(), List.of(EXAMPLE_CONFIGURATION_B1_1))), entry("a1_arrayArrayB2", List.of(List.of(), List.of(EXAMPLE_CONFIGURATION_B2_1))), @@ -243,6 +249,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_localDate", "2000-01-02"), entry("a2_localTime", "00:02"), entry("a2_localDateTime", "2000-01-02T00:00"), + entry("a2_uuid", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1"), entry("a2_Enm", "B"), entry("a2_b1", EXAMPLE_CONFIGURATION_B1_2), entry("a2_b2", EXAMPLE_CONFIGURATION_B2_2), @@ -260,6 +267,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_listLocalDate", List.of("2000-01-02", "2000-01-03", "2000-01-04")), entry("a2_listLocalTime", List.of("00:02", "00:03", "00:04")), entry("a2_listLocalDateTime", List.of("2000-01-02T00:00", "2000-01-03T00:00", "2000-01-04T00:00")), + entry("a2_listUuid", List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2", "d50f3bdd-ac66-4b74-a01f-4617b24d68c3")), entry("a2_listEnm", List.of("B", "C", "D")), entry("a2_listB1", List.of(EXAMPLE_CONFIGURATION_B1_1, EXAMPLE_CONFIGURATION_B1_2)), entry("a2_listB2", List.of(EXAMPLE_CONFIGURATION_B2_1, EXAMPLE_CONFIGURATION_B2_2)), @@ -285,6 +293,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_arrayLocalDate", List.of("2000-01-02", "2000-01-03", "2000-01-04")), entry("a2_arrayLocalTime", List.of("00:02", "00:03", "00:04")), entry("a2_arrayLocalDateTime", List.of("2000-01-02T00:00", "2000-01-03T00:00", "2000-01-04T00:00")), + entry("a2_arrayUuid", List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2", "d50f3bdd-ac66-4b74-a01f-4617b24d68c3")), entry("a2_arrayEnm", List.of("B", "C", "D")), entry("a2_arrayB1", List.of(EXAMPLE_CONFIGURATION_B1_1, EXAMPLE_CONFIGURATION_B1_2)), entry("a2_arrayB2", List.of(EXAMPLE_CONFIGURATION_B2_1, EXAMPLE_CONFIGURATION_B2_2)), @@ -302,6 +311,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_setLocalDate", asList("2000-01-02", "2000-01-03", "2000-01-04")), entry("a2_setLocalTime", asList("00:02", "00:03", "00:04")), entry("a2_setLocalDateTime", asList("2000-01-02T00:00", "2000-01-03T00:00", "2000-01-04T00:00")), + entry("a2_setUuid", asList("d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2", "d50f3bdd-ac66-4b74-a01f-4617b24d68c3")), entry("a2_setEnm", asList("B", "C", "D")), entry("a2_setB1", asList(EXAMPLE_CONFIGURATION_B1_1, EXAMPLE_CONFIGURATION_B1_2)), entry("a2_setB2", asList(EXAMPLE_CONFIGURATION_B2_1, EXAMPLE_CONFIGURATION_B2_2)), @@ -319,6 +329,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_mapLocalDateLocalDate", asMap("2000-01-02", "2000-01-03", "2000-01-04", "2000-01-05")), entry("a2_mapLocalTimeLocalTime", asMap("00:02", "00:03", "00:04", "00:05")), entry("a2_mapLocalDateTimeLocalDateTime", asMap("2000-01-02T00:00", "2000-01-03T00:00", "2000-01-04T00:00", "2000-01-05T00:00")), + entry("a2_mapUuidUuid", asMap("d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2", "d50f3bdd-ac66-4b74-a01f-4617b24d68c3", "d50f3bdd-ac66-4b74-a01f-4617b24d68c4")), entry("a2_mapEnmEnm", asMap("B", "C", "D", "E")), entry("a2_mapIntegerB1", asMap(2L, EXAMPLE_CONFIGURATION_B1_1, 3L, EXAMPLE_CONFIGURATION_B1_2)), entry("a2_mapEnmB2", asMap("B", EXAMPLE_CONFIGURATION_B2_1, "C", EXAMPLE_CONFIGURATION_B2_2)), @@ -361,6 +372,7 @@ public final class ExampleConfigurationsSerialized { entry("a2_arrayArrayLocalDate", List.of(List.of("2000-01-01"), List.of("2000-01-01", "2000-01-02"), List.of("2000-01-01", "2000-01-02", "2000-01-03"))), entry("a2_arrayArrayLocalTime", List.of(List.of("00:01"), List.of("00:01", "00:02"), List.of("00:01", "00:02", "00:03"))), entry("a2_arrayArrayLocalDateTime", List.of(List.of("2000-01-01T00:00"), List.of("2000-01-01T00:00", "2000-01-02T00:00"), List.of("2000-01-01T00:00", "2000-01-02T00:00", "2000-01-03T00:00"))), + entry("a2_arrayArrayUuid", List.of(List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0"), List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1"), List.of("d50f3bdd-ac66-4b74-a01f-4617b24d68c0", "d50f3bdd-ac66-4b74-a01f-4617b24d68c1", "d50f3bdd-ac66-4b74-a01f-4617b24d68c2"))), entry("a2_arrayArrayEnm", List.of(List.of("A"), List.of("A", "B"), List.of("A", "B", "C"))), entry("a2_arrayArrayB1", List.of(List.of(EXAMPLE_CONFIGURATION_B1_1), List.of(EXAMPLE_CONFIGURATION_B1_2))), entry("a2_arrayArrayB2", List.of(List.of(EXAMPLE_CONFIGURATION_B2_1), List.of(EXAMPLE_CONFIGURATION_B2_2))), diff --git a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleInitializer.java b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleInitializer.java index a306cb5..008d32f 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleInitializer.java +++ b/configlib-core/src/test/java/de/exlll/configlib/configurations/ExampleInitializer.java @@ -10,6 +10,7 @@ import java.time.Month; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.UUID; import static de.exlll.configlib.TestUtils.*; import static de.exlll.configlib.configurations.ExampleEnum.*; @@ -45,6 +46,12 @@ public final class ExampleInitializer { private static final LocalDateTime LDT_4 = LocalDateTime.of(2000, Month.JANUARY, 4, 0, 0); private static final LocalDateTime LDT_5 = LocalDateTime.of(2000, Month.JANUARY, 5, 0, 0); + private static final UUID UUID_1 = UUID.fromString("d50f3bdd-ac66-4b74-a01f-4617b24d68c0"); + private static final UUID UUID_2 = UUID.fromString("d50f3bdd-ac66-4b74-a01f-4617b24d68c1"); + private static final UUID UUID_3 = UUID.fromString("d50f3bdd-ac66-4b74-a01f-4617b24d68c2"); + private static final UUID UUID_4 = UUID.fromString("d50f3bdd-ac66-4b74-a01f-4617b24d68c3"); + private static final UUID UUID_5 = UUID.fromString("d50f3bdd-ac66-4b74-a01f-4617b24d68c4"); + private static final ExampleConfigurationB1 B1_1 = newExampleConfigurationB1_1(); private static final ExampleConfigurationB1 B1_2 = newExampleConfigurationB1_2(); private static final ExampleConfigurationB2 B2_1 = newExampleConfigurationB2_1(); @@ -124,6 +131,9 @@ public final class ExampleInitializer { a2.setA1_localDateTime(LDT_1); a2.setA2_localDateTime(LDT_2); + a2.setA1_uuid(UUID_1); + a2.setA2_uuid(UUID_2); + a2.setA1_Enm(A); a2.setA2_Enm(B); @@ -175,6 +185,9 @@ public final class ExampleInitializer { a2.setA1_listLocalDateTime(List.of(LDT_1, LDT_2, LDT_3)); a2.setA2_listLocalDateTime(List.of(LDT_2, LDT_3, LDT_4)); + a2.setA1_listUuid(List.of(UUID_1, UUID_2, UUID_3)); + a2.setA2_listUuid(List.of(UUID_2, UUID_3, UUID_4)); + a2.setA1_listEnm(List.of(A, B, C)); a2.setA2_listEnm(List.of(B, C, D)); @@ -250,6 +263,9 @@ public final class ExampleInitializer { a2.setA1_arrayLocalDateTime(new LocalDateTime[]{LDT_1, LDT_2, LDT_3}); a2.setA2_arrayLocalDateTime(new LocalDateTime[]{LDT_2, LDT_3, LDT_4}); + a2.setA1_arrayUuid(new UUID[]{UUID_1, UUID_2, UUID_3}); + a2.setA2_arrayUuid(new UUID[]{UUID_2, UUID_3, UUID_4}); + a2.setA1_arrayEnm(new ExampleEnum[]{A, B, C}); a2.setA2_arrayEnm(new ExampleEnum[]{B, C, D}); @@ -301,6 +317,9 @@ public final class ExampleInitializer { a2.setA1_setLocalDateTime(asSet(LDT_1, LDT_2, LDT_3)); a2.setA2_setLocalDateTime(asSet(LDT_2, LDT_3, LDT_4)); + a2.setA1_setUuid(asSet(UUID_1, UUID_2, UUID_3)); + a2.setA2_setUuid(asSet(UUID_2, UUID_3, UUID_4)); + a2.setA1_setEnm(asSet(A, B, C)); a2.setA2_setEnm(asSet(B, C, D)); @@ -352,6 +371,9 @@ public final class ExampleInitializer { a2.setA1_mapLocalDateTimeLocalDateTime(asMap(LDT_1, LDT_2, LDT_3, LDT_4)); a2.setA2_mapLocalDateTimeLocalDateTime(asMap(LDT_2, LDT_3, LDT_4, LDT_5)); + a2.setA1_mapUuidUuid(asMap(UUID_1, UUID_2, UUID_3, UUID_4)); + a2.setA2_mapUuidUuid(asMap(UUID_2, UUID_3, UUID_4, UUID_5)); + a2.setA1_mapEnmEnm(asMap(A, B, C, D)); a2.setA2_mapEnmEnm(asMap(B, C, D, E)); @@ -765,6 +787,17 @@ public final class ExampleInitializer { {LDT_1, LDT_2, LDT_3}, }); + a2.setA1_arrayArrayUuid(new UUID[][]{ + {}, + {UUID_1}, + {UUID_1, UUID_2}, + }); + a2.setA2_arrayArrayUuid(new UUID[][]{ + {UUID_1}, + {UUID_1, UUID_2}, + {UUID_1, UUID_2, UUID_3}, + }); + a2.setA1_arrayArrayEnm(new ExampleEnum[][]{ {}, {A},