Package com.helger.commons.traits
Interface IGetterDirectTrait
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A generic convert Object to anything with convenience API.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptiondefault BigDecimaldefault BigDecimalgetAsBigDecimal(BigDecimal aDefault) default BigIntegerdefault BigIntegergetAsBigInteger(BigInteger aDefault) default booleandefault booleangetAsBoolean(boolean bDefault) default Booleandefault bytedefault bytegetAsByte(byte nDefault) default byte[]default Bytedefault chardefault chargetAsChar(char cDefault) default char[]default char[]getAsCharArray(char[] aDefault) default Characterdefault doubledefault doublegetAsDouble(double dDefault) default Doubledefault floatdefault floatgetAsFloat(float fDefault) default Floatdefault intgetAsInt()default intgetAsInt(int nDefault) default Integerdefault LocalDatedefault LocalDategetAsLocalDate(LocalDate aDefault) default LocalDateTimedefault LocalDateTimegetAsLocalDateTime(LocalDateTime aDefault) default LocalTimedefault LocalTimegetAsLocalTime(LocalTime aDefault) default longdefault longgetAsLong(long nDefault) default Longdefault shortdefault shortgetAsShort(short nDefault) default Shortdefault Blobdefault Clobdefault Datedefault NClobdefault RowIddefault Timedefault Timestampdefault Stringdefault StringgetAsString(String sDefault) default <T> TGet the contained value casted to the return type.default <T> TgetCastedValue(Class<T> aClass) Get the contained value casted to the specified class.default <T> TgetCastedValue(T aDefault) Get the contained value casted to the return type.default <T> TgetCastedValue(T aDefault, Class<T> aClass) Get the contained value casted to the specified class.default <T> TgetConvertedValue(Class<T> aClass) Get the contained value converted using TypeConverter to the passed class.default <T> TgetConvertedValue(T aDefault, Class<T> aClass) Get the contained value converted using TypeConverter to the passed class.getValue()default Class<?> default booleandefault booleanhasValue()
-
Method Details
-
getValue
- Returns:
- The value of interest. No
nullconstraints applicable.
-
getValueClass
- Returns:
- The class of the value or
nullif no value is contained.
-
hasValue
default boolean hasValue()- Returns:
trueif the value is notnull. Same asgetValue()!=null.
-
hasNoValue
default boolean hasNoValue()- Returns:
trueif the value isnull. Same asgetValue()==null.
-
getCastedValue
Get the contained value casted to the return type.- Type Parameters:
T- Destination type- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull. - Throws:
ClassCastException- in case the value types are not convertible
-
getCastedValue
Get the contained value casted to the return type.- Type Parameters:
T- Destination type- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull. - Throws:
ClassCastException- in case the value types are not convertible
-
getCastedValue
Get the contained value casted to the specified class.- Type Parameters:
T- Destination type- Parameters:
aClass- The class to cast to.- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull. - Throws:
ClassCastException- in case the value types are not convertible
-
getCastedValue
Get the contained value casted to the specified class.- Type Parameters:
T- Destination type- Parameters:
aDefault- The value to be returned if the retrieved value isnull.aClass- The class to cast to.- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull. - Throws:
ClassCastException- in case the value types are not convertible
-
getConvertedValue
Get the contained value converted using TypeConverter to the passed class.- Type Parameters:
T- Destination type- Parameters:
aClass- The class to convert to.- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull. - Throws:
TypeConverterException- in case of an error
-
getConvertedValue
Get the contained value converted using TypeConverter to the passed class.- Type Parameters:
T- Destination type- Parameters:
aDefault- The value to be returned if the retrieved value isnullor if type conversion fails.aClass- The class to convert to. May not benull.- Returns:
- The object value casted to the passed class. May be
nullif the contained value isnull.
-
getAsBoolean
default boolean getAsBoolean() -
getAsBoolean
default boolean getAsBoolean(boolean bDefault) -
getAsByte
default byte getAsByte() -
getAsByte
default byte getAsByte(byte nDefault) -
getAsChar
default char getAsChar() -
getAsChar
default char getAsChar(char cDefault) -
getAsDouble
default double getAsDouble() -
getAsDouble
default double getAsDouble(double dDefault) -
getAsFloat
default float getAsFloat() -
getAsFloat
default float getAsFloat(float fDefault) -
getAsInt
default int getAsInt() -
getAsInt
default int getAsInt(int nDefault) -
getAsLong
default long getAsLong() -
getAsLong
default long getAsLong(long nDefault) -
getAsShort
default short getAsShort() -
getAsShort
default short getAsShort(short nDefault) -
getAsString
- Returns:
getConvertedValue (null, String.class)- See Also:
-
getAsString
- Parameters:
sDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (sDefault, String.class)- See Also:
-
getAsCharArray
- Returns:
getConvertedValue (null, char[].class)- See Also:
-
getAsCharArray
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (aDefault, char[].class)- See Also:
-
getAsBigDecimal
- Returns:
getConvertedValue (null, BigDecimal.class)- See Also:
-
getAsBigDecimal
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (sDefault, BigDecimal.class)- See Also:
-
getAsBigInteger
- Returns:
getConvertedValue (null, BigInteger.class)- See Also:
-
getAsBigInteger
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (sDefault, BigInteger.class)- See Also:
-
getAsLocalDate
- Returns:
getConvertedValue (null, LocalDate.class)- See Also:
-
getAsLocalDate
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (aDefault, LocalDate.class)- See Also:
-
getAsLocalTime
- Returns:
getConvertedValue (null, LocalTime.class)- See Also:
-
getAsLocalTime
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (aDefault, LocalTime.class)- See Also:
-
getAsLocalDateTime
- Returns:
getConvertedValue (null, LocalDateTime.class)- See Also:
-
getAsLocalDateTime
- Parameters:
aDefault- The value to be returned if the retrieved value isnull.- Returns:
getConvertedValue (aDefault, LocalDateTime.class)- See Also:
-
getAsByteArray
- Returns:
getConvertedValue (null, byte[].class)- See Also:
-
getAsBooleanObj
- Returns:
getConvertedValue (null, Boolean.class)- See Also:
-
getAsByteObj
- Returns:
getConvertedValue (null, Byte.class)- See Also:
-
getAsCharObj
- Returns:
getConvertedValue (null, Character.class)- See Also:
-
getAsDoubleObj
- Returns:
getConvertedValue (null, Double.class)- See Also:
-
getAsFloatObj
- Returns:
getConvertedValue (null, Float.class)- See Also:
-
getAsIntObj
- Returns:
getConvertedValue (null, Integer.class)- See Also:
-
getAsLongObj
- Returns:
getConvertedValue (null, Long.class)- See Also:
-
getAsShortObj
- Returns:
getConvertedValue (null, Short.class)- See Also:
-
getAsSqlBlob
- Returns:
getConvertedValue (null, Blob.class)- See Also:
-
getAsSqlClob
- Returns:
getConvertedValue (null, Clob.class)- See Also:
-
getAsSqlDate
- Returns:
getConvertedValue (null, Date.class)- See Also:
-
getAsSqlNClob
- Returns:
getConvertedValue (null, NClob.class)- See Also:
-
getAsSqlRowId
- Returns:
getConvertedValue (null, RowId.class)- See Also:
-
getAsSqlTime
- Returns:
getConvertedValue (null, Time.class)- See Also:
-
getAsSqlTimestamp
- Returns:
getConvertedValue (null, Timestamp.class)- See Also:
-