Add utility method

This commit is contained in:
Andrea Cavalli 2022-02-28 14:50:40 +01:00
parent c7ebf9e32f
commit 5cb81b3450
7 changed files with 56 additions and 0 deletions

View File

@ -30,6 +30,14 @@ public class NullableInt52 implements Serializable, IGenericNullable {
}
}
public static NullableInt52 ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new NullableInt52(Int52.fromLong(value.longValue()));
}
}
public static NullableInt52 empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullablebyte implements Serializable, IGenericNullable {
}
}
public static Nullablebyte ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullablebyte(value.byteValue());
}
}
public static Nullablebyte empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullabledouble implements Serializable, IGenericNullable {
}
}
public static Nullabledouble ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullabledouble(value.doubleValue());
}
}
public static Nullabledouble empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullablefloat implements Serializable, IGenericNullable {
}
}
public static Nullablefloat ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullablefloat(value.floatValue());
}
}
public static Nullablefloat empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullableint implements Serializable, IGenericNullable {
}
}
public static Nullableint ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullableint(value.intValue());
}
}
public static Nullableint empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullablelong implements Serializable, IGenericNullable {
}
}
public static Nullablelong ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullablelong(value.longValue());
}
}
public static Nullablelong empty() {
return NULL;
}

View File

@ -30,6 +30,14 @@ public class Nullableshort implements Serializable, IGenericNullable {
}
}
public static Nullableshort ofNullableNumber(@Nullable Number value) {
if (value == null) {
return NULL;
} else {
return new Nullableshort(value.shortValue());
}
}
public static Nullableshort empty() {
return NULL;
}