This commit is contained in:
Andrea Cavalli 2023-01-22 01:18:50 +01:00
parent 9b3a9d7ebc
commit 78e5cc370d

View File

@ -85,11 +85,12 @@ public class GenNullableX extends ClassGenerator {
throw new UnsupportedOperationException();
}
classBuilder.addField(FieldSpec
.builder(type, "NULL").addModifiers(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL).initializer("new $T(null)", type).build());
if (version.isCurrent()) {
classBuilder.addSuperinterfaces(List.of(iNullableITypeClass, iNullableClass, typedNullable));
classBuilder.addField(FieldSpec.builder(type, "NULL").addModifiers(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL).initializer("new $T(($T)null)", type, baseType).build());
classBuilder.addMethod(MethodSpec
.methodBuilder("of")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
@ -111,13 +112,6 @@ public class GenNullableX extends ClassGenerator {
.addStatement("return value != null ? new $T(value) : NULL", type)
.build());
classBuilder.addMethod(MethodSpec
.methodBuilder("empty")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.returns(type)
.addStatement("return NULL")
.build());
classBuilder.addMethod(MethodSpec
.methodBuilder("or")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
@ -128,6 +122,13 @@ public class GenNullableX extends ClassGenerator {
.build());
}
classBuilder.addMethod(MethodSpec
.methodBuilder("empty")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.returns(type)
.addStatement("return NULL")
.build());
classBuilder.addMethod(MethodSpec
.methodBuilder("getNullable")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)