Skip to content

Commit 19ff7c2

Browse files
authored
Merge pull request #246 from JarvisCraft/1.0.0-rc.6
2 parents 3d2b151 + b9c1539 commit 19ff7c2

File tree

9 files changed

+111
-65
lines changed

9 files changed

+111
-65
lines changed

java-commons/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<parent>
7-
<artifactId>padla</artifactId>
86
<groupId>ru.progrm-jarvis</groupId>
9-
<version>1.0.0-rc.5</version>
7+
<artifactId>padla</artifactId>
8+
<version>1.0.0-rc.6</version>
109
</parent>
1110
<artifactId>java-commons</artifactId>
1211

@@ -49,10 +48,12 @@
4948
<dependency>
5049
<groupId>org.junit.jupiter</groupId>
5150
<artifactId>junit-jupiter-api</artifactId>
51+
<scope>test</scope>
5252
</dependency>
5353
<dependency>
5454
<groupId>org.junit.jupiter</groupId>
5555
<artifactId>junit-jupiter-params</artifactId>
56+
<scope>test</scope>
5657
</dependency>
5758
<dependency>
5859
<groupId>org.hamcrest</groupId>

java-commons/src/main/java/ru/progrm_jarvis/javacommons/cache/CaffeineCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CaffeineCache {
3939
* @throws IllegalStateException if Caffeine is not available
4040
*/
4141
public static @NotNull CacheFactory createFactory() {
42-
if (AVAILABLE) return new CaffeineCacheFactory();
42+
if (AVAILABLE) return CaffeineCacheFactory.INSTANCE;
4343

4444
throw new IllegalStateException("Caffeine Cache is not available");
4545
}

java-commons/src/main/java/ru/progrm_jarvis/javacommons/data/DataSerializer.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.jetbrains.annotations.Range;
1111

1212
import java.io.*;
13+
import java.util.Optional;
1314

1415
/**
1516
* Serializer of arbitary data.
@@ -194,11 +195,24 @@ default T fromByteArrayUnchecked(final byte @NotNull [] byteArray) {
194195
* Crates a data serializer based on this one which allows null values.
195196
*
196197
* @return null-friendly equivalent of this data serializer
198+
*
199+
* @see #optional() equivalent using {@link Optional} instead
197200
*/
198-
default @NotNull DataSerializer<T> nullable() {
201+
default @NotNull DataSerializer<@Nullable T> nullable() {
199202
return new NullableDataSerializer<>(this);
200203
}
201204

205+
/**
206+
* Crates a data serializer based on this one which allows {@link Optional optional} values.
207+
*
208+
* @return {@link Optional}-friendly equivalent of this data serializer
209+
*
210+
* @see #nullable() equivalent using nullable values instead
211+
*/
212+
default @NotNull DataSerializer<@NotNull Optional<T>> optional() {
213+
return new OptionalDataSerializer<>(this);
214+
}
215+
202216
/**
203217
* Data serializer for nullable types.
204218
*/
@@ -220,4 +234,27 @@ public void write(final @NotNull DataOutputStream output, final @Nullable T obje
220234
return input.readBoolean() ? wrapped.read(input) : null;
221235
}
222236
}
237+
238+
/**
239+
* Data serializer for {@link Optional optional} types.
240+
*/
241+
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
242+
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
243+
final class OptionalDataSerializer<T> implements DataSerializer<@NotNull Optional<T>> {
244+
245+
@NotNull DataSerializer<T> wrapped;
246+
247+
@Override
248+
public void write(final @NotNull DataOutputStream output,
249+
final @NotNull Optional<T> object) throws IOException {
250+
final boolean present;
251+
output.writeBoolean(present = object.isPresent());
252+
if (present) wrapped.write(output, object.get());
253+
}
254+
255+
@Override
256+
public @NotNull Optional<T> read(final @NotNull DataInputStream input) throws IOException {
257+
return input.readBoolean() ? Optional.of(wrapped.read(input)) : Optional.empty();
258+
}
259+
}
223260
}

padla-bom/pom.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>ru.progrm-jarvis</groupId>
7+
<artifactId>padla</artifactId>
8+
<version>1.0.0-rc.6</version>
9+
</parent>
10+
<artifactId>padla-bom</artifactId>
11+
<packaging>pom</packaging>
12+
13+
<name>PADLA BOM</name>
14+
<description>PADLA's Bill Of Materials</description>
15+
16+
<dependencyManagement>
17+
<!-- Note: variables cannot be used here as this would allow version overriding -->
18+
<dependencies>
19+
<dependency>
20+
<groupId>ru.progrm-jarvis</groupId>
21+
<artifactId>java-commons</artifactId>
22+
<version>1.0.0-rc.6</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>ru.progrm-jarvis</groupId>
26+
<artifactId>reflector</artifactId>
27+
<version>1.0.0-rc.6</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>ru.progrm-jarvis</groupId>
31+
<artifactId>ultimate-messenger</artifactId>
32+
<version>1.0.0-rc.6</version>
33+
</dependency>
34+
</dependencies>
35+
</dependencyManagement>
36+
</project>

pom.xml

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<groupId>ru.progrm-jarvis</groupId>
76
<artifactId>padla</artifactId>
8-
<version>1.0.0-rc.5</version>
7+
<version>1.0.0-rc.6</version>
98
<modules>
109
<module>java-commons</module>
1110
<module>reflector</module>
1211
<module>ultimate-messenger</module>
1312
<module>tools</module>
13+
<module>padla-bom</module>
1414
</modules>
1515
<packaging>pom</packaging>
1616

1717
<properties>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<maven.compiler.source>1.8</maven.compiler.source>
2020
<maven.compiler.target>1.8</maven.compiler.target>
21-
<!-- Testing -->
22-
<version.junit>5.7.2</version.junit>
23-
<version.junit.platform>1.7.2</version.junit.platform>
21+
<!-- Duplicated dependency versions -->
2422
<version.mockito>3.12.4</version.mockito>
2523
</properties>
2624

@@ -103,6 +101,10 @@
103101
<groupId>org.apache.maven.plugins</groupId>
104102
<artifactId>maven-surefire-plugin</artifactId>
105103
<version>3.0.0-M5</version>
104+
<configuration>
105+
<parallel>all</parallel>
106+
<useUnlimitedThreads>true</useUnlimitedThreads>
107+
</configuration>
106108
</plugin>
107109

108110
<!-- Maven-central deployment-related plugins -->
@@ -151,6 +153,7 @@
151153

152154
<dependencyManagement>
153155
<dependencies>
156+
<!-- Own dependencies -->
154157
<dependency>
155158
<groupId>${project.groupId}</groupId>
156159
<artifactId>java-commons</artifactId>
@@ -162,20 +165,29 @@
162165
<version>${project.version}</version>
163166
</dependency>
164167

168+
<!-- BOMs -->
169+
<dependency>
170+
<groupId>org.junit</groupId>
171+
<artifactId>junit-bom</artifactId>
172+
<version>5.8.0-RC1</version>
173+
<type>pom</type>
174+
<scope>import</scope>
175+
</dependency>
176+
165177
<!-- Libraries -->
166178
<!-- Caching -->
167179
<dependency>
168180
<groupId>com.github.ben-manes.caffeine</groupId>
169181
<artifactId>caffeine</artifactId>
170-
<version>2.9.1</version>
182+
<version>2.9.2</version>
171183
<scope>provided</scope>
172184
<optional>true</optional>
173185
</dependency>
174186
<!-- Bytecode generation -->
175187
<dependency>
176188
<groupId>org.ow2.asm</groupId>
177189
<artifactId>asm</artifactId>
178-
<version>9.1</version>
190+
<version>9.2</version>
179191
<scope>provided</scope>
180192
<optional>true</optional>
181193
</dependency>
@@ -200,55 +212,18 @@
200212
<dependency>
201213
<groupId>org.jetbrains</groupId>
202214
<artifactId>annotations</artifactId>
203-
<version>21.0.1</version>
215+
<version>22.0.0</version>
204216
<scope>provided</scope>
205217
<optional>true</optional>
206218
</dependency>
207219

208220
<!-- Testing -->
209-
<dependency>
210-
<groupId>org.junit.jupiter</groupId>
211-
<artifactId>junit-jupiter-api</artifactId>
212-
<version>${version.junit}</version>
213-
<scope>test</scope>
214-
</dependency>
215-
<dependency>
216-
<groupId>org.junit.jupiter</groupId>
217-
<artifactId>junit-jupiter-engine</artifactId>
218-
<version>${version.junit}</version>
219-
<scope>test</scope>
220-
</dependency>
221-
<dependency>
222-
<groupId>org.junit.jupiter</groupId>
223-
<artifactId>junit-jupiter-params</artifactId>
224-
<version>${version.junit}</version>
225-
<scope>test</scope>
226-
</dependency>
227-
<dependency>
228-
<groupId>org.junit.platform</groupId>
229-
<artifactId>junit-platform-launcher</artifactId>
230-
<version>${version.junit.platform}</version>
231-
<scope>test</scope>
232-
</dependency>
233221
<dependency>
234222
<groupId>org.hamcrest</groupId>
235223
<artifactId>hamcrest-all</artifactId>
236224
<version>1.3</version>
237225
<scope>test</scope>
238226
</dependency>
239-
<dependency>
240-
<!-- Specified in case it is needed (though tests run normally without it) -->
241-
<groupId>org.junit.platform</groupId>
242-
<artifactId>junit-platform-runner</artifactId>
243-
<version>${version.junit.platform}</version>
244-
<scope>test</scope>
245-
</dependency>
246-
<dependency>
247-
<groupId>org.junit.platform</groupId>
248-
<artifactId>junit-platform-surefire-provider</artifactId>
249-
<version>1.3.2</version>
250-
<scope>test</scope>
251-
</dependency>
252227
<dependency>
253228
<groupId>org.mockito</groupId>
254229
<artifactId>mockito-core</artifactId>
@@ -367,4 +342,3 @@
367342
</profile>
368343
</profiles>
369344
</project>
370-

reflector/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<parent>
7-
<artifactId>padla</artifactId>
86
<groupId>ru.progrm-jarvis</groupId>
9-
<version>1.0.0-rc.5</version>
7+
<artifactId>padla</artifactId>
8+
<version>1.0.0-rc.6</version>
109
</parent>
1110
<artifactId>reflector</artifactId>
1211

@@ -26,6 +25,7 @@
2625
<dependency>
2726
<groupId>org.junit.jupiter</groupId>
2827
<artifactId>junit-jupiter-api</artifactId>
28+
<scope>test</scope>
2929
</dependency>
3030
<dependency>
3131
<groupId>org.hamcrest</groupId>

tools/pom.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<parent>
7-
<artifactId>padla</artifactId>
86
<groupId>ru.progrm-jarvis</groupId>
9-
<version>1.0.0-rc.5</version>
7+
<artifactId>padla</artifactId>
8+
<version>1.0.0-rc.6</version>
109
</parent>
1110
<artifactId>padla-tools</artifactId>
11+
<packaging>pom</packaging>
1212
<modules>
1313
<module>unsafe-methods-access-generator</module>
1414
</modules>
15-
<packaging>pom</packaging>
1615

1716
<build>
1817
<defaultGoal>clean package</defaultGoal>
@@ -50,5 +49,4 @@
5049
</dependency>
5150
</dependencies>
5251
</dependencyManagement>
53-
5452
</project>

tools/unsafe-methods-access-generator/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<parent>
7-
<artifactId>padla-tools</artifactId>
86
<groupId>ru.progrm-jarvis</groupId>
9-
<version>1.0.0-rc.5</version>
7+
<artifactId>padla-tools</artifactId>
8+
<version>1.0.0-rc.6</version>
109
</parent>
1110
<artifactId>unsafe-methods-access-generator</artifactId>
1211

ultimate-messenger/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
65
<parent>
7-
<artifactId>padla</artifactId>
86
<groupId>ru.progrm-jarvis</groupId>
9-
<version>1.0.0-rc.5</version>
7+
<artifactId>padla</artifactId>
8+
<version>1.0.0-rc.6</version>
109
</parent>
1110
<artifactId>ultimate-messenger</artifactId>
1211

@@ -45,10 +44,12 @@
4544
<dependency>
4645
<groupId>org.junit.jupiter</groupId>
4746
<artifactId>junit-jupiter-api</artifactId>
47+
<scope>test</scope>
4848
</dependency>
4949
<dependency>
5050
<groupId>org.junit.jupiter</groupId>
5151
<artifactId>junit-jupiter-params</artifactId>
52+
<scope>test</scope>
5253
</dependency>
5354
<dependency>
5455
<groupId>org.hamcrest</groupId>

0 commit comments

Comments
 (0)