public interface Value
null.
The class has different transformer methods, that
translate the value into different java types.| Modifier and Type | Method and Description |
|---|---|
Boolean |
toBoolean()
Transforms the encapsulated value into a Boolean.
|
default boolean |
toBoolean(boolean defaultValue)
Transforms the encapsulated value into a boolean.
|
Byte |
toByte()
Transforms the encapsulated value into a Byte.
|
default byte |
toByte(byte defaultValue)
Transforms the encapsulated value into a byte.
|
Calendar |
toCalendar()
Transforms the encapsulated value int a
Calendar. |
default Calendar |
toCalendar(Calendar defaultValue)
Transforms the encapsulated value int a
Calendar. |
Class<?> |
toClass()
Transforms the encapsulated value into a
Class. |
Class<?>[] |
toClassArray()
Transforms the encapsulated value into an array of classes.
|
Date |
toDate()
Transforms the encapsulated value int a
Date. |
default Date |
toDate(Date defaultValue)
Transforms the encapsulated value int a
Date. |
Double |
toDouble()
Transforms the encapsulated value into a Double.
|
default double |
toDouble(double defaultValue)
Transforms the encapsulated value into a double.
|
<E extends Enum<?>> |
toEnum(Class<E> type)
Transforms the encapsulated value into the given type of enum.
|
default <E extends Enum<?>> |
toEnum(E defaultValue)
Transforms the encapsulated value into an enum.
|
<E extends Enum<E>> |
toEnumSet(Class<E> type)
Transforms the encapsulated value into an
EnumSet of the given enum type. |
File |
toFile()
Transforms the encapsulated value into a
File. |
Float |
toFloat()
Transforms the encapsulated value into a Float.
|
default float |
toFloat(float defaultValue)
Transforms the encapsulated value into a float.
|
Integer |
toInteger()
Transforms the encapsulated value into an Integer.
|
default int |
toInteger(int defaultValue)
Transforms the encapsulated value into an int.
|
Long |
toLong()
Transforms the encapsulated value into a Long.
|
default long |
toLong(long defaultValue)
Transforms the encapsulated value into a long.
|
Short |
toShort()
Transforms the encapsulated value into a Short.
|
default short |
toShort(short defaultValue)
Transforms the encapsulated value into a short.
|
default String |
toString(String defaultValue)
Transforms the encapsulated value into a string.
|
String[] |
toStringArray()
Transforms the encapsulated value into a String array.
|
String[] toStringArray()
null, result will be null also.nulldefault String toString(String defaultValue)
null, the result will be the given defaultValue.
If the value is a String, then will be used. Otherwise, the method returns the String representation of the value.defaultValue - default value which is used when the encapsulated value is null; cannot be nullNullPointerException - if the given defaultValue is nullLong toLong()
null, the result will be also null.
If the value is a Number, then it's long representation will be used. Otherwise, the method tries to parse the
String representation of the value as long. If it is not possible, null will be returned.nulldefault long toLong(long defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's long representation will be used. Otherwise, the method tries to parse the
String representation of the value as long. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a longInteger toInteger()
null, the result will be also null.
If the value is a Number, then it's integer representation will be used. Otherwise, the method tries to parse the
String representation of the value as integer. If it is not possible, null will be returned.nulldefault int toInteger(int defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's integer representation will be used. Otherwise, the method tries to parse the
String representation of the value as integer. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a intShort toShort()
null, the result will be also null.
If the value is a Number, then it's short representation will be used. Otherwise, the method tries to parse the
String representation of the value as short. If it is not possible, null will be returned.nulldefault short toShort(short defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's short representation will be used. Otherwise, the method tries to parse the
String representation of the value as short. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a shortByte toByte()
null, the result will be also null.
If the value is a Number, then it's byte representation will be used. Otherwise, the method tries to parse the
String representation of the value as byte. If it is not possible, null will be returned.nulldefault byte toByte(byte defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's byte representation will be used. Otherwise, the method tries to parse the
String representation of the value as byte. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a byteDouble toDouble()
null, the result will be also null.
If the value is a Number, then it's double representation will be used. Otherwise, the method tries to parse the
String representation of the value as double. If it is not possible, null will be returned.nulldefault double toDouble(double defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's double representation will be used. Otherwise, the method tries to parse the
String representation of the value as double. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a doubleFloat toFloat()
null, the result will be also null.
If the value is a Number, then it's float representation will be used. Otherwise, the method tries to parse the
String representation of the value as float. If it is not possible, null will be returned.nulldefault float toFloat(float defaultValue)
null, the result will be the given defaultValue.
If the value is a Number, then it's float representation will be used. Otherwise, the method tries to parse the
String representation of the value as float. If it is not possible, the defaultValue will be returned.defaultValue - default value which is used when the encapsulated value cannot be transformed to a floatBoolean toBoolean()
null, the result will be also null.
If the value is a Boolean, then it will be returned. Otherwise, the method parses the
String representation of the value as boolean.nulldefault boolean toBoolean(boolean defaultValue)
null, the result will be the given defaultValue.
If the value is a Boolean, then it will be returned. Otherwise, the method parses the
String representation of the value as boolean.defaultValue - default value which is used when the encapsulated value is nullDate toDate()
Date. If the value is null, the result will be also null.
If the value is a Date, then it will be returned. If the value is a date-like object ( Calendar, Instant,
XMLGregorianCalendar, OffsetDateTime, ZonedDateTime, LocalDate, LocalDateTime), then
it will be transformed into a Date. Otherwise, the method parses the String representation of the value as a Date.
In this case relative date is noticed as well.
A relative date always begins with a "+" or "-" sign, depending on whether you want a future or past date.
This is followed by a combination of numbers and letters. Each number is followed by a letter that gives the unit of measure for the number.
This may be:
default Date toDate(Date defaultValue)
Date. If the value is null, the result will be the given defaultValue.
If the value is a Date, then it will be returned. If the value is a date-like object ( Calendar, Instant,
XMLGregorianCalendar, OffsetDateTime, ZonedDateTime, LocalDate, LocalDateTime), then
it will be transformed into a Date. Otherwise, the method parses the String representation of the value as a Date.
In this case relative date is noticed as well.
A relative date always begins with a "+" or "-" sign, depending on whether you want a future or past date.
This is followed by a combination of numbers and letters. Each number is followed by a letter that gives the unit of measure for the number.
This may be:
defaultValue - default value which is used when the encapsulated value is nullCalendar toCalendar()
Calendar. If the value is null, the result will be also null.
If the value is a Calendar, then it will be returned. If the value is a date-like object ( Date, Instant,
XMLGregorianCalendar, OffsetDateTime, ZonedDateTime, LocalDate, LocalDateTime), then
it will be transformed into a Calendar. Otherwise, the method parses the String representation of the value as a Calendar.
In this case relative date is noticed as well.
A relative date always begins with a "+" or "-" sign, depending on whether you want a future or past date.
This is followed by a combination of numbers and letters. Each number is followed by a letter that gives the unit of measure for the number.
This may be:
default Calendar toCalendar(Calendar defaultValue)
Calendar. If the value is null, the result will be the given defaultValue.
If the value is a Calendar, then it will be returned. If the value is a date-like object ( Date, Instant,
XMLGregorianCalendar, OffsetDateTime, ZonedDateTime, LocalDate, LocalDateTime), then
it will be transformed into a Calendar. Otherwise, the method parses the String representation of the value as a Calendar.
In this case relative date is noticed as well.
A relative date always begins with a "+" or "-" sign, depending on whether you want a future or past date.
This is followed by a combination of numbers and letters. Each number is followed by a letter that gives the unit of measure for the number.
This may be:
defaultValue - default value which is used when the encapsulated value is null<E extends Enum<?>> E toEnum(Class<E> type)
null, the result will be also null.
If the value is the right type, then it will be returned. Otherwise, the method tries to parse the result
from the String representation of the value. For that, the name of the enum constants will be used (see Enum.name()).
The method is able to find the right enum constant case-insensitively. If it is not possible, then the result will be null.E - the type of the resulttype - the enum type we want to have as resultnulldefault <E extends Enum<?>> E toEnum(E defaultValue)
null, the result will be the given defaultValue.
If the value is the right type, then it will be returned. Otherwise, the method tries to parse the result
from the String representation of the value. For that, the name of the enum constants will be used (see Enum.name()).
The method is able to find the right enum constant case-insensitively. If it is not possible, then the result will be the defaultValue.E - the type of the resultdefaultValue - default value which will be returned if value cannot be parsed to an enum constant; should be non-nullNullPointerException - if the given defaultValue is null<E extends Enum<E>> EnumSet<E> toEnumSet(Class<E> type)
EnumSet of the given enum type.
null, result will be null also.E - the desired enum typetype - the enum type we want to have in the result setnullFile toFile()
File.
If the value is null, the result will be also null.
If the value is a File instance, then it will be returned.
Otherwise, a new File instance will be constructed from the string
representation of the value.nullClass<?> toClass()
Class.
If the value is null, the result will be also null.
If the value is a Class instance, then it will be returned.
Otherwise, a new Class instance will be constructed from the string
representation of the value.nullClass<?>[] toClassArray()
null, result will be null also.nullCreated by Kornél Simon, 2022