fix: prevent endlessly recursive serialization due to misinterpretation of checked method as getter
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/push/docs Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2023-10-03 20:16:00 +02:00
parent bcd4e34f7a
commit 0bd675fc7c
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package io.gitlab.jfronny.inceptum.launcher.model.inceptum;
import io.gitlab.jfronny.gson.compile.annotations.GPrefer;
import io.gitlab.jfronny.gson.compile.annotations.GSerializable;
import io.gitlab.jfronny.inceptum.common.GsonPreset;
@ -39,18 +40,21 @@ public class InstanceMeta {
}
public void checkArguments() {
arguments = arguments == null ? Arguments.EMPTY : arguments.checked();
arguments = Arguments.checked(arguments);
}
@GSerializable(configure = GsonPreset.Config.class)
public record Arguments(List<String> jvm, List<String> client, List<String> server) {
public static final Arguments EMPTY = new Arguments(List.of(), List.of(), List.of());
public Arguments checked() {
@GPrefer public Arguments {}
public static Arguments checked(Arguments of) {
if (of == null) return EMPTY;
return new Arguments(
jvm == null ? List.of() : jvm,
client == null ? List.of() : client,
server == null ? List.of() : server
of.jvm == null ? List.of() : of.jvm,
of.client == null ? List.of() : of.client,
of.server == null ? List.of() : of.server
);
}