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.

@FunctionalInterface public interface IGetterDirectTrait
A generic convert Object to anything with convenience API.
Author:
Philip Helger
  • Method Details

    • getValue

      @Nullable Object getValue()
      Returns:
      The value of interest. No null constraints applicable.
    • getValueClass

      @Nullable default Class<?> getValueClass()
      Returns:
      The class of the value or null if no value is contained.
    • hasValue

      default boolean hasValue()
      Returns:
      true if the value is not null. Same as getValue()!=null.
    • hasNoValue

      default boolean hasNoValue()
      Returns:
      true if the value is null. Same as getValue()==null.
    • getCastedValue

      @Nullable default <T> T 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 null if the contained value is null.
      Throws:
      ClassCastException - in case the value types are not convertible
    • getCastedValue

      @Nullable default <T> T getCastedValue(@Nullable T aDefault)
      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 is null .
      Returns:
      The object value casted to the passed class. May be null if the contained value is null.
      Throws:
      ClassCastException - in case the value types are not convertible
    • getCastedValue

      @Nullable default <T> T getCastedValue(@Nonnull Class<T> aClass)
      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 null if the contained value is null.
      Throws:
      ClassCastException - in case the value types are not convertible
    • getCastedValue

      @Nullable default <T> T getCastedValue(@Nullable T aDefault, @Nonnull Class<T> aClass)
      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 is null .
      aClass - The class to cast to.
      Returns:
      The object value casted to the passed class. May be null if the contained value is null.
      Throws:
      ClassCastException - in case the value types are not convertible
    • getConvertedValue

      @Nullable default <T> T getConvertedValue(@Nonnull Class<T> aClass)
      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 null if the contained value is null.
      Throws:
      TypeConverterException - in case of an error
    • getConvertedValue

      @Nullable default <T> T getConvertedValue(@Nullable T aDefault, @Nonnull Class<T> aClass)
      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 is null or if type conversion fails.
      aClass - The class to convert to. May not be null.
      Returns:
      The object value casted to the passed class. May be null if the contained value is null.
    • 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

      @Nullable default String getAsString()
      Returns:
      getConvertedValue (null, String.class)
      See Also:
    • getAsString

      @Nullable default String getAsString(@Nullable String sDefault)
      Parameters:
      sDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (sDefault, String.class)
      See Also:
    • getAsCharArray

      @Nullable default char[] getAsCharArray()
      Returns:
      getConvertedValue (null, char[].class)
      See Also:
    • getAsCharArray

      @Nullable default char[] getAsCharArray(@Nullable char[] aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (aDefault, char[].class)
      See Also:
    • getAsBigDecimal

      @Nullable default BigDecimal getAsBigDecimal()
      Returns:
      getConvertedValue (null, BigDecimal.class)
      See Also:
    • getAsBigDecimal

      @Nullable default BigDecimal getAsBigDecimal(@Nullable BigDecimal aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (sDefault, BigDecimal.class)
      See Also:
    • getAsBigInteger

      @Nullable default BigInteger getAsBigInteger()
      Returns:
      getConvertedValue (null, BigInteger.class)
      See Also:
    • getAsBigInteger

      @Nullable default BigInteger getAsBigInteger(@Nullable BigInteger aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (sDefault, BigInteger.class)
      See Also:
    • getAsLocalDate

      @Nullable default LocalDate getAsLocalDate()
      Returns:
      getConvertedValue (null, LocalDate.class)
      See Also:
    • getAsLocalDate

      @Nullable default LocalDate getAsLocalDate(@Nullable LocalDate aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (aDefault, LocalDate.class)
      See Also:
    • getAsLocalTime

      @Nullable default LocalTime getAsLocalTime()
      Returns:
      getConvertedValue (null, LocalTime.class)
      See Also:
    • getAsLocalTime

      @Nullable default LocalTime getAsLocalTime(@Nullable LocalTime aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (aDefault, LocalTime.class)
      See Also:
    • getAsLocalDateTime

      @Nullable default LocalDateTime getAsLocalDateTime()
      Returns:
      getConvertedValue (null, LocalDateTime.class)
      See Also:
    • getAsLocalDateTime

      @Nullable default LocalDateTime getAsLocalDateTime(@Nullable LocalDateTime aDefault)
      Parameters:
      aDefault - The value to be returned if the retrieved value is null .
      Returns:
      getConvertedValue (aDefault, LocalDateTime.class)
      See Also:
    • getAsByteArray

      @Nullable default byte[] getAsByteArray()
      Returns:
      getConvertedValue (null, byte[].class)
      See Also:
    • getAsBooleanObj

      @Nullable default Boolean getAsBooleanObj()
      Returns:
      getConvertedValue (null, Boolean.class)
      See Also:
    • getAsByteObj

      @Nullable default Byte getAsByteObj()
      Returns:
      getConvertedValue (null, Byte.class)
      See Also:
    • getAsCharObj

      @Nullable default Character getAsCharObj()
      Returns:
      getConvertedValue (null, Character.class)
      See Also:
    • getAsDoubleObj

      @Nullable default Double getAsDoubleObj()
      Returns:
      getConvertedValue (null, Double.class)
      See Also:
    • getAsFloatObj

      @Nullable default Float getAsFloatObj()
      Returns:
      getConvertedValue (null, Float.class)
      See Also:
    • getAsIntObj

      @Nullable default Integer getAsIntObj()
      Returns:
      getConvertedValue (null, Integer.class)
      See Also:
    • getAsLongObj

      @Nullable default Long getAsLongObj()
      Returns:
      getConvertedValue (null, Long.class)
      See Also:
    • getAsShortObj

      @Nullable default Short getAsShortObj()
      Returns:
      getConvertedValue (null, Short.class)
      See Also:
    • getAsSqlBlob

      @Nullable default Blob getAsSqlBlob()
      Returns:
      getConvertedValue (null, Blob.class)
      See Also:
    • getAsSqlClob

      @Nullable default Clob getAsSqlClob()
      Returns:
      getConvertedValue (null, Clob.class)
      See Also:
    • getAsSqlDate

      @Nullable default Date getAsSqlDate()
      Returns:
      getConvertedValue (null, Date.class)
      See Also:
    • getAsSqlNClob

      @Nullable default NClob getAsSqlNClob()
      Returns:
      getConvertedValue (null, NClob.class)
      See Also:
    • getAsSqlRowId

      @Nullable default RowId getAsSqlRowId()
      Returns:
      getConvertedValue (null, RowId.class)
      See Also:
    • getAsSqlTime

      @Nullable default Time getAsSqlTime()
      Returns:
      getConvertedValue (null, Time.class)
      See Also:
    • getAsSqlTimestamp

      @Nullable default Timestamp getAsSqlTimestamp()
      Returns:
      getConvertedValue (null, Timestamp.class)
      See Also: