Update runtime

This commit is contained in:
Andrea Cavalli 2022-02-20 16:22:38 +01:00
parent d955175db7
commit 3e15dc24a1
11 changed files with 118 additions and 36 deletions

View File

@ -19,7 +19,10 @@ public class Int52 extends Number implements Comparable<Int52> {
*/
public static final int BYTES = 7;
public static final Int52 ZERO = new Int52(0);
public static final Int52 ZERO = new Int52(0L);
public static final Int52 ONE = new Int52(1L);
public static final Int52 TWO = new Int52(2L);
public static final Int52 TEN = new Int52(10L);
private final long value;
@ -28,13 +31,21 @@ public class Int52 extends Number implements Comparable<Int52> {
}
public static Int52 fromLong(long value) {
if (value < 0) {
if (value == 0) {
return ZERO;
} else if (value == 1) {
return ONE;
} else if (value == 2) {
return TWO;
} else if (value == 10) {
return TEN;
} else if (value <= 0) {
throw new IllegalArgumentException("Only positive values are supported");
}
if (value > 0x0F_FF_FF_FF_FF_FF_FFL) {
} else if (value > 0x0F_FF_FF_FF_FF_FF_FFL) {
throw new IllegalArgumentException("Only values below or equal to " + 0xFFFFFFFFFFFFFL + " are supported");
} else {
return new Int52(value);
}
return new Int52(value);
}
long getValue() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class NullableInt52 implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final NullableInt52 NULL = new NullableInt52(null);
private final Int52 value;
@ -20,11 +23,15 @@ public class NullableInt52 implements Serializable, IGenericNullable {
}
public static NullableInt52 ofNullable(@Nullable Int52 value) {
return new NullableInt52(value);
if (value == null) {
return NULL;
} else {
return new NullableInt52(value);
}
}
public static <T> NullableInt52 empty() {
return new NullableInt52(null);
public static NullableInt52 empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class NullableString implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final NullableString NULL = new NullableString(null);
private final String value;
@ -15,6 +18,7 @@ public class NullableString implements Serializable, IGenericNullable {
this.value = value;
}
@SuppressWarnings("ConstantConditions")
public static NullableString of(@NotNull String value) {
if (value == null) {
throw new NullPointerException();
@ -24,18 +28,22 @@ public class NullableString implements Serializable, IGenericNullable {
}
public static NullableString ofNullable(@Nullable String value) {
return new NullableString(value);
if (value == null) {
return NULL;
} else {
return new NullableString(value);
}
}
public static NullableString ofNullableBlank(@Nullable String value) {
if (value == null || value.isBlank()) {
return empty();
return NULL;
}
return new NullableString(value);
}
public static <T> NullableString empty() {
return new NullableString(null);
public static NullableString empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullableboolean implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullableboolean NULL = new Nullableboolean(null);
private final Boolean value;
@ -20,11 +23,15 @@ public class Nullableboolean implements Serializable, IGenericNullable {
}
public static Nullableboolean ofNullable(@Nullable Boolean value) {
return new Nullableboolean(value);
if (value == null) {
return NULL;
} else {
return new Nullableboolean(value);
}
}
public static <T> Nullableboolean empty() {
return new Nullableboolean(null);
public static Nullableboolean empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullablebyte implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullablebyte NULL = new Nullablebyte(null);
private final Byte value;
@ -20,11 +23,15 @@ public class Nullablebyte implements Serializable, IGenericNullable {
}
public static Nullablebyte ofNullable(@Nullable Byte value) {
return new Nullablebyte(value);
if (value == null) {
return NULL;
} else {
return new Nullablebyte(value);
}
}
public static <T> Nullablebyte empty() {
return new Nullablebyte(null);
public static Nullablebyte empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullablechar implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullablechar NULL = new Nullablechar(null);
private final Character value;
@ -20,11 +23,15 @@ public class Nullablechar implements Serializable, IGenericNullable {
}
public static Nullablechar ofNullable(@Nullable Character value) {
return new Nullablechar(value);
if (value == null) {
return NULL;
} else {
return new Nullablechar(value);
}
}
public static <T> Nullablechar empty() {
return new Nullablechar(null);
public static Nullablechar empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullabledouble implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullabledouble NULL = new Nullabledouble(null);
private final Double value;
@ -20,11 +23,15 @@ public class Nullabledouble implements Serializable, IGenericNullable {
}
public static Nullabledouble ofNullable(@Nullable Double value) {
return new Nullabledouble(value);
if (value == null) {
return NULL;
} else {
return new Nullabledouble(value);
}
}
public static <T> Nullabledouble empty() {
return new Nullabledouble(null);
public static Nullabledouble empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullablefloat implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullablefloat NULL = new Nullablefloat(null);
private final Float value;
@ -20,11 +23,15 @@ public class Nullablefloat implements Serializable, IGenericNullable {
}
public static Nullablefloat ofNullable(@Nullable Float value) {
return new Nullablefloat(value);
if (value == null) {
return NULL;
} else {
return new Nullablefloat(value);
}
}
public static <T> Nullablefloat empty() {
return new Nullablefloat(null);
public static Nullablefloat empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullableint implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullableint NULL = new Nullableint(null);
private final Integer value;
@ -20,11 +23,15 @@ public class Nullableint implements Serializable, IGenericNullable {
}
public static Nullableint ofNullable(@Nullable Integer value) {
return new Nullableint(value);
if (value == null) {
return NULL;
} else {
return new Nullableint(value);
}
}
public static <T> Nullableint empty() {
return new Nullableint(null);
public static Nullableint empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullablelong implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullablelong NULL = new Nullablelong(null);
private final Long value;
@ -20,11 +23,15 @@ public class Nullablelong implements Serializable, IGenericNullable {
}
public static Nullablelong ofNullable(@Nullable Long value) {
return new Nullablelong(value);
if (value == null) {
return NULL;
} else {
return new Nullablelong(value);
}
}
public static <T> Nullablelong empty() {
return new Nullablelong(null);
public static Nullablelong empty() {
return NULL;
}
public boolean isEmpty() {

View File

@ -1,5 +1,6 @@
package it.cavallium.data.generator.nativedata;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
@ -7,7 +8,9 @@ import org.jetbrains.annotations.Nullable;
public class Nullableshort implements Serializable, IGenericNullable {
@Serial
private static final long serialVersionUID = 1L;
private static final Nullableshort NULL = new Nullableshort(null);
private final Short value;
@ -20,11 +23,15 @@ public class Nullableshort implements Serializable, IGenericNullable {
}
public static Nullableshort ofNullable(@Nullable Short value) {
return new Nullableshort(value);
if (value == null) {
return NULL;
} else {
return new Nullableshort(value);
}
}
public static <T> Nullableshort empty() {
return new Nullableshort(null);
public static Nullableshort empty() {
return NULL;
}
public boolean isEmpty() {