diff --git a/java-commons/pom.xml b/java-commons/pom.xml index 38f8a5ed..aa7f86de 100644 --- a/java-commons/pom.xml +++ b/java-commons/pom.xml @@ -2,11 +2,10 @@ 4.0.0 - - padla ru.progrm-jarvis - 1.0.0-rc.5 + padla + 1.0.0-rc.6 java-commons @@ -49,10 +48,12 @@ org.junit.jupiter junit-jupiter-api + test org.junit.jupiter junit-jupiter-params + test org.hamcrest diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/cache/CaffeineCache.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/cache/CaffeineCache.java index 049028b8..61abeb66 100644 --- a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/cache/CaffeineCache.java +++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/cache/CaffeineCache.java @@ -39,7 +39,7 @@ public class CaffeineCache { * @throws IllegalStateException if Caffeine is not available */ public static @NotNull CacheFactory createFactory() { - if (AVAILABLE) return new CaffeineCacheFactory(); + if (AVAILABLE) return CaffeineCacheFactory.INSTANCE; throw new IllegalStateException("Caffeine Cache is not available"); } diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/data/DataSerializer.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/data/DataSerializer.java index ad637172..08448b83 100644 --- a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/data/DataSerializer.java +++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/data/DataSerializer.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.Range; import java.io.*; +import java.util.Optional; /** * Serializer of arbitary data. @@ -194,11 +195,24 @@ default T fromByteArrayUnchecked(final byte @NotNull [] byteArray) { * Crates a data serializer based on this one which allows null values. * * @return null-friendly equivalent of this data serializer + * + * @see #optional() equivalent using {@link Optional} instead */ - default @NotNull DataSerializer nullable() { + default @NotNull DataSerializer<@Nullable T> nullable() { return new NullableDataSerializer<>(this); } + /** + * Crates a data serializer based on this one which allows {@link Optional optional} values. + * + * @return {@link Optional}-friendly equivalent of this data serializer + * + * @see #nullable() equivalent using nullable values instead + */ + default @NotNull DataSerializer<@NotNull Optional> optional() { + return new OptionalDataSerializer<>(this); + } + /** * Data serializer for nullable types. */ @@ -220,4 +234,27 @@ public void write(final @NotNull DataOutputStream output, final @Nullable T obje return input.readBoolean() ? wrapped.read(input) : null; } } + + /** + * Data serializer for {@link Optional optional} types. + */ + @RequiredArgsConstructor(access = AccessLevel.PRIVATE) + @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) + final class OptionalDataSerializer implements DataSerializer<@NotNull Optional> { + + @NotNull DataSerializer wrapped; + + @Override + public void write(final @NotNull DataOutputStream output, + final @NotNull Optional object) throws IOException { + final boolean present; + output.writeBoolean(present = object.isPresent()); + if (present) wrapped.write(output, object.get()); + } + + @Override + public @NotNull Optional read(final @NotNull DataInputStream input) throws IOException { + return input.readBoolean() ? Optional.of(wrapped.read(input)) : Optional.empty(); + } + } } diff --git a/padla-bom/pom.xml b/padla-bom/pom.xml new file mode 100644 index 00000000..6379ffe0 --- /dev/null +++ b/padla-bom/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + ru.progrm-jarvis + padla + 1.0.0-rc.6 + + padla-bom + pom + + PADLA BOM + PADLA's Bill Of Materials + + + + + + ru.progrm-jarvis + java-commons + 1.0.0-rc.6 + + + ru.progrm-jarvis + reflector + 1.0.0-rc.6 + + + ru.progrm-jarvis + ultimate-messenger + 1.0.0-rc.6 + + + + diff --git a/pom.xml b/pom.xml index e1c3d9d4..35382133 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - ru.progrm-jarvis padla - 1.0.0-rc.5 + 1.0.0-rc.6 java-commons reflector ultimate-messenger tools + padla-bom pom @@ -18,9 +18,7 @@ UTF-8 1.8 1.8 - - 5.7.2 - 1.7.2 + 3.12.4 @@ -103,6 +101,10 @@ org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 + + all + true + @@ -151,6 +153,7 @@ + ${project.groupId} java-commons @@ -162,12 +165,21 @@ ${project.version} + + + org.junit + junit-bom + 5.8.0-RC1 + pom + import + + com.github.ben-manes.caffeine caffeine - 2.9.1 + 2.9.2 provided true @@ -175,7 +187,7 @@ org.ow2.asm asm - 9.1 + 9.2 provided true @@ -200,55 +212,18 @@ org.jetbrains annotations - 21.0.1 + 22.0.0 provided true - - org.junit.jupiter - junit-jupiter-api - ${version.junit} - test - - - org.junit.jupiter - junit-jupiter-engine - ${version.junit} - test - - - org.junit.jupiter - junit-jupiter-params - ${version.junit} - test - - - org.junit.platform - junit-platform-launcher - ${version.junit.platform} - test - org.hamcrest hamcrest-all 1.3 test - - - org.junit.platform - junit-platform-runner - ${version.junit.platform} - test - - - org.junit.platform - junit-platform-surefire-provider - 1.3.2 - test - org.mockito mockito-core @@ -367,4 +342,3 @@ - diff --git a/reflector/pom.xml b/reflector/pom.xml index b059fe90..50a108d3 100644 --- a/reflector/pom.xml +++ b/reflector/pom.xml @@ -2,11 +2,10 @@ 4.0.0 - - padla ru.progrm-jarvis - 1.0.0-rc.5 + padla + 1.0.0-rc.6 reflector @@ -26,6 +25,7 @@ org.junit.jupiter junit-jupiter-api + test org.hamcrest diff --git a/tools/pom.xml b/tools/pom.xml index 9495387d..f75e10fe 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -2,17 +2,16 @@ 4.0.0 - - padla ru.progrm-jarvis - 1.0.0-rc.5 + padla + 1.0.0-rc.6 padla-tools + pom unsafe-methods-access-generator - pom clean package @@ -50,5 +49,4 @@ - diff --git a/tools/unsafe-methods-access-generator/pom.xml b/tools/unsafe-methods-access-generator/pom.xml index 0bb12de8..2262acf7 100644 --- a/tools/unsafe-methods-access-generator/pom.xml +++ b/tools/unsafe-methods-access-generator/pom.xml @@ -2,11 +2,10 @@ 4.0.0 - - padla-tools ru.progrm-jarvis - 1.0.0-rc.5 + padla-tools + 1.0.0-rc.6 unsafe-methods-access-generator diff --git a/ultimate-messenger/pom.xml b/ultimate-messenger/pom.xml index 1bc223a4..9019dee0 100644 --- a/ultimate-messenger/pom.xml +++ b/ultimate-messenger/pom.xml @@ -2,11 +2,10 @@ 4.0.0 - - padla ru.progrm-jarvis - 1.0.0-rc.5 + padla + 1.0.0-rc.6 ultimate-messenger @@ -45,10 +44,12 @@ org.junit.jupiter junit-jupiter-api + test org.junit.jupiter junit-jupiter-params + test org.hamcrest