Skip to content

Commit

Permalink
Merge pull request #246 from JarvisCraft/1.0.0-rc.6
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvisCraft authored Sep 4, 2021
2 parents 3d2b151 + b9c1539 commit 19ff7c2
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 65 deletions.
7 changes: 4 additions & 3 deletions java-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>padla</artifactId>
<groupId>ru.progrm-jarvis</groupId>
<version>1.0.0-rc.5</version>
<artifactId>padla</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>java-commons</artifactId>

Expand Down Expand Up @@ -49,10 +48,12 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jetbrains.annotations.Range;

import java.io.*;
import java.util.Optional;

/**
* Serializer of arbitary data.
Expand Down Expand Up @@ -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<T> 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<T>> optional() {
return new OptionalDataSerializer<>(this);
}

/**
* Data serializer for nullable types.
*/
Expand All @@ -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<T> implements DataSerializer<@NotNull Optional<T>> {

@NotNull DataSerializer<T> wrapped;

@Override
public void write(final @NotNull DataOutputStream output,
final @NotNull Optional<T> object) throws IOException {
final boolean present;
output.writeBoolean(present = object.isPresent());
if (present) wrapped.write(output, object.get());
}

@Override
public @NotNull Optional<T> read(final @NotNull DataInputStream input) throws IOException {
return input.readBoolean() ? Optional.of(wrapped.read(input)) : Optional.empty();
}
}
}
36 changes: 36 additions & 0 deletions padla-bom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.progrm-jarvis</groupId>
<artifactId>padla</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>padla-bom</artifactId>
<packaging>pom</packaging>

<name>PADLA BOM</name>
<description>PADLA's Bill Of Materials</description>

<dependencyManagement>
<!-- Note: variables cannot be used here as this would allow version overriding -->
<dependencies>
<dependency>
<groupId>ru.progrm-jarvis</groupId>
<artifactId>java-commons</artifactId>
<version>1.0.0-rc.6</version>
</dependency>
<dependency>
<groupId>ru.progrm-jarvis</groupId>
<artifactId>reflector</artifactId>
<version>1.0.0-rc.6</version>
</dependency>
<dependency>
<groupId>ru.progrm-jarvis</groupId>
<artifactId>ultimate-messenger</artifactId>
<version>1.0.0-rc.6</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
66 changes: 20 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ru.progrm-jarvis</groupId>
<artifactId>padla</artifactId>
<version>1.0.0-rc.5</version>
<version>1.0.0-rc.6</version>
<modules>
<module>java-commons</module>
<module>reflector</module>
<module>ultimate-messenger</module>
<module>tools</module>
<module>padla-bom</module>
</modules>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Testing -->
<version.junit>5.7.2</version.junit>
<version.junit.platform>1.7.2</version.junit.platform>
<!-- Duplicated dependency versions -->
<version.mockito>3.12.4</version.mockito>
</properties>

Expand Down Expand Up @@ -103,6 +101,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<parallel>all</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>

<!-- Maven-central deployment-related plugins -->
Expand Down Expand Up @@ -151,6 +153,7 @@

<dependencyManagement>
<dependencies>
<!-- Own dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>java-commons</artifactId>
Expand All @@ -162,20 +165,29 @@
<version>${project.version}</version>
</dependency>

<!-- BOMs -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.0-RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Libraries -->
<!-- Caching -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.9.1</version>
<version>2.9.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Bytecode generation -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.1</version>
<version>9.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand All @@ -200,55 +212,18 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>21.0.1</version>
<version>22.0.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${version.junit.platform}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- Specified in case it is needed (though tests run normally without it) -->
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${version.junit.platform}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -367,4 +342,3 @@
</profile>
</profiles>
</project>

6 changes: 3 additions & 3 deletions reflector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>padla</artifactId>
<groupId>ru.progrm-jarvis</groupId>
<version>1.0.0-rc.5</version>
<artifactId>padla</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>reflector</artifactId>

Expand All @@ -26,6 +25,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down
8 changes: 3 additions & 5 deletions tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>padla</artifactId>
<groupId>ru.progrm-jarvis</groupId>
<version>1.0.0-rc.5</version>
<artifactId>padla</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>padla-tools</artifactId>
<packaging>pom</packaging>
<modules>
<module>unsafe-methods-access-generator</module>
</modules>
<packaging>pom</packaging>

<build>
<defaultGoal>clean package</defaultGoal>
Expand Down Expand Up @@ -50,5 +49,4 @@
</dependency>
</dependencies>
</dependencyManagement>

</project>
5 changes: 2 additions & 3 deletions tools/unsafe-methods-access-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>padla-tools</artifactId>
<groupId>ru.progrm-jarvis</groupId>
<version>1.0.0-rc.5</version>
<artifactId>padla-tools</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>unsafe-methods-access-generator</artifactId>

Expand Down
7 changes: 4 additions & 3 deletions ultimate-messenger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>padla</artifactId>
<groupId>ru.progrm-jarvis</groupId>
<version>1.0.0-rc.5</version>
<artifactId>padla</artifactId>
<version>1.0.0-rc.6</version>
</parent>
<artifactId>ultimate-messenger</artifactId>

Expand Down Expand Up @@ -45,10 +44,12 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down

0 comments on commit 19ff7c2

Please sign in to comment.