Update runtime

This commit is contained in:
Andrea Cavalli 2022-02-20 16:25:35 +01:00
parent 3e15dc24a1
commit 14fd6fc4b2

View File

@ -3,6 +3,7 @@ package it.cavallium.data.generator;
public class Nullable<T> {
private static final long serialVersionUID = 1L;
private static final Nullable<?> NULL = new Nullable<>(null);
private final T value;
@ -18,12 +19,18 @@ public class Nullable<T> {
}
}
@SuppressWarnings("unchecked")
public static <T> Nullable<T> ofNullable(T value) {
return new Nullable<>(value);
if (value == null) {
return (Nullable<T>) NULL;
} else {
return new Nullable<>(value);
}
}
@SuppressWarnings("unchecked")
public static <T> Nullable<T> empty() {
return new Nullable<>(null);
return (Nullable<T>) NULL;
}
public boolean isEmpty() {