KEYTYPE - The key type. E.g. String etc.@FunctionalInterface public interface IGetterByKeyTrait<KEYTYPE>
| Modifier and Type | Method and Description |
|---|---|
default boolean |
containsNonNullValue(KEYTYPE aKey) |
default boolean |
containsNullValue(KEYTYPE aKey) |
default BigDecimal |
getAsBigDecimal(KEYTYPE aKey) |
default BigDecimal |
getAsBigDecimal(KEYTYPE aKey,
BigDecimal aDefault) |
default BigInteger |
getAsBigInteger(KEYTYPE aKey) |
default BigInteger |
getAsBigInteger(KEYTYPE aKey,
BigInteger aDefault) |
default boolean |
getAsBoolean(KEYTYPE aKey) |
default boolean |
getAsBoolean(KEYTYPE aKey,
boolean bDefault) |
default Boolean |
getAsBooleanObj(KEYTYPE aKey) |
default byte |
getAsByte(KEYTYPE aKey) |
default byte |
getAsByte(KEYTYPE aKey,
byte nDefault) |
default byte[] |
getAsByteArray(KEYTYPE aKey) |
default Byte |
getAsByteObj(KEYTYPE aKey) |
default char |
getAsChar(KEYTYPE aKey) |
default char |
getAsChar(KEYTYPE aKey,
char cDefault) |
default char[] |
getAsCharArray(KEYTYPE aKey) |
default char[] |
getAsCharArray(KEYTYPE aKey,
char[] aDefault) |
default Character |
getAsCharObj(KEYTYPE aKey) |
default double |
getAsDouble(KEYTYPE aKey) |
default double |
getAsDouble(KEYTYPE aKey,
double dDefault) |
default Double |
getAsDoubleObj(KEYTYPE aKey) |
default float |
getAsFloat(KEYTYPE aKey) |
default float |
getAsFloat(KEYTYPE aKey,
float fDefault) |
default Float |
getAsFloatObj(KEYTYPE aKey) |
default int |
getAsInt(KEYTYPE aKey) |
default int |
getAsInt(KEYTYPE aKey,
int nDefault) |
default Integer |
getAsIntObj(KEYTYPE aKey) |
default LocalDate |
getAsLocalDate(KEYTYPE aKey) |
default LocalDate |
getAsLocalDate(KEYTYPE aKey,
LocalDate aDefault) |
default LocalDate |
getAsLocalDate(KEYTYPE aKey,
Locale aContentLocale)
Get the value as a String, interpreted as a
LocalDate. |
default LocalDateTime |
getAsLocalDateTime(KEYTYPE aKey) |
default LocalDateTime |
getAsLocalDateTime(KEYTYPE aKey,
LocalDateTime aDefault) |
default LocalDateTime |
getAsLocalDateTime(KEYTYPE aKey,
Locale aContentLocale)
Get the value as a String, interpreted as a
LocalDateTime. |
default LocalTime |
getAsLocalTime(KEYTYPE aKey) |
default LocalTime |
getAsLocalTime(KEYTYPE aKey,
Locale aContentLocale)
Get the value as a String, interpreted as a
LocalTime. |
default LocalTime |
getAsLocalTime(KEYTYPE aKey,
LocalTime aDefault) |
default long |
getAsLong(KEYTYPE aKey) |
default long |
getAsLong(KEYTYPE aKey,
long nDefault) |
default Long |
getAsLongObj(KEYTYPE aKey) |
default short |
getAsShort(KEYTYPE aKey) |
default short |
getAsShort(KEYTYPE aKey,
short nDefault) |
default Short |
getAsShortObj(KEYTYPE aKey) |
default Blob |
getAsSqlBlob(KEYTYPE aKey) |
default Clob |
getAsSqlClob(KEYTYPE aKey) |
default Date |
getAsSqlDate(KEYTYPE aKey) |
default NClob |
getAsSqlNClob(KEYTYPE aKey) |
default RowId |
getAsSqlRowId(KEYTYPE aKey) |
default Time |
getAsSqlTime(KEYTYPE aKey) |
default Timestamp |
getAsSqlTimestamp(KEYTYPE aKey) |
default String |
getAsString(KEYTYPE aKey) |
default String |
getAsString(KEYTYPE aKey,
String sDefault) |
default ICommonsList<String> |
getAsStringList(KEYTYPE aKey)
Get a list of all attribute values with the same name.
|
default ICommonsList<String> |
getAsStringList(KEYTYPE aKey,
ICommonsList<String> aDefault)
Get a list of all attribute values with the same name.
|
default ICommonsOrderedSet<String> |
getAsStringSet(KEYTYPE aKey)
Get a set of all attribute values with the same name.
|
default ICommonsOrderedSet<String> |
getAsStringSet(KEYTYPE aKey,
ICommonsOrderedSet<String> aDefault)
Get a set of all attribute values with the same name.
|
default <T> T |
getCastedValue(KEYTYPE aKey)
Get the contained value casted to the return type.
|
default <T> T |
getCastedValue(KEYTYPE aKey,
Class<T> aClass)
Get the contained value casted to the specified class.
|
default <T> T |
getCastedValue(KEYTYPE aKey,
T aDefault)
Get the contained value casted to the return type.
|
default <T> T |
getCastedValue(KEYTYPE aKey,
T aDefault,
Class<T> aClass)
Get the contained value casted to the specified class.
|
default <T> T |
getConvertedValue(KEYTYPE aKey,
Class<T> aClass)
Get the contained value converted using TypeConverter to the passed class.
|
default <T> T |
getConvertedValue(KEYTYPE aKey,
T aDefault,
Class<T> aClass)
Get the contained value converted using TypeConverter to the passed class.
|
default <T> T |
getSafeCastedValue(KEYTYPE aKey,
Class<T> aClass)
Get the contained value casted to the specified class, but only if the cast
is possible.
|
default <T> T |
getSafeCastedValue(KEYTYPE aKey,
T aDefault,
Class<T> aClass)
Get the contained value casted to the specified class, but only if the cast
is possible.
|
Object |
getValue(KEYTYPE aKey)
Get the value matching the provided key.
|
default Class<?> |
getValueClass(KEYTYPE aKey) |
default boolean |
hasStringValue(KEYTYPE aKey,
String sDesiredValue)
Check if a attribute with the given name is present in the request and has
the specified value.
|
default boolean |
hasStringValue(KEYTYPE aKey,
String sDesiredValue,
boolean bDefault)
Check if a attribute with the given name is present in the request and has
the specified value.
|
default void |
onSafeCastError(KEYTYPE aKey,
Class<?> aClass,
Object aValue)
Implement this method to handle cases of
getSafeCastedValue(Object, Object, Class) that failed because
invalid provided class. |
@Nullable Object getValue(@Nullable KEYTYPE aKey)
aKey - The key to query. May be null.null constraints
applicable.@Nullable default Class<?> getValueClass(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.null if no value is
contained.default boolean containsNonNullValue(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.true if the value is not null. Same as
getValue()!=null.default boolean containsNullValue(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.true if the value is null. Same as
getValue()==null.@Nullable default <T> T getCastedValue(@Nullable KEYTYPE aKey)
T - Destination typeaKey - The key to be accessed. May be null.null if the contained value is null.ClassCastException - in case the value types are not convertible@Nullable default <T> T getCastedValue(@Nullable KEYTYPE aKey, @Nullable T aDefault)
T - Destination typeaKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.null if the contained value is null.ClassCastException - in case the value types are not convertible@Nullable default <T> T getCastedValue(@Nullable KEYTYPE aKey, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.aClass - The class to cast to.null if the contained value is null.ClassCastException - in case the value types are not convertible@Nullable default <T> T getCastedValue(@Nullable KEYTYPE aKey, @Nullable T aDefault, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.aClass - The class to cast to.null if the contained value is null.ClassCastException - in case the value types are not convertible@Nullable default <T> T getSafeCastedValue(@Nullable KEYTYPE aKey, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.aClass - The class to cast to.null if the contained value is null.ClassCastException - in case the value types are not convertiblegetSafeCastedValue(Object, Object, Class)default void onSafeCastError(@Nullable KEYTYPE aKey, @Nonnull Class<?> aClass, @Nonnull Object aValue)
getSafeCastedValue(Object, Object, Class) that failed because
invalid provided class.
"Key '" + aKey + "' is present, but not as a " + aClass + " but as a " + aValue.getClass ()
aKey - Key that was searchedaClass - The class that was desiredaValue - The value that was retrieved and cannot be casted to the class@Nullable default <T> T getSafeCastedValue(@Nullable KEYTYPE aKey, @Nullable T aDefault, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.aClass - The class to cast to.null if the contained value is null.ClassCastException - in case the value types are not convertiblegetSafeCastedValue(Object, Class)@Nullable default <T> T getConvertedValue(@Nullable KEYTYPE aKey, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.aClass - The class to convert to.null if the contained value is null.TypeConverterException - in case of an error@Nullable default <T> T getConvertedValue(@Nullable KEYTYPE aKey, @Nullable T aDefault, @Nonnull Class<T> aClass)
T - Destination typeaKey - The key to be accessed. May be null.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.null if the contained value is null.@Nullable default String getAsString(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,String.class)getConvertedValue(Object,Object,Class)@Nullable default String getAsString(@Nullable KEYTYPE aKey, @Nullable String sDefault)
aKey - The key to be accessed. May be null.sDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,sDefault, String.class)getConvertedValue(Object,Object,Class)@Nullable default char[] getAsCharArray(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,char [].class)getConvertedValue(Object,Object,Class)@Nullable default char[] getAsCharArray(@Nullable KEYTYPE aKey, @Nullable char[] aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey, aDefault, char[].class)getConvertedValue(Object,Object,Class)@Nullable default BigDecimal getAsBigDecimal(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,BigDecimal.class)getConvertedValue(Object,Object,Class)@Nullable default BigDecimal getAsBigDecimal(@Nullable KEYTYPE aKey, @Nullable BigDecimal aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,aDefault,BigDecimal.class)getConvertedValue(Object,Object,Class)@Nullable default BigInteger getAsBigInteger(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,BigInteger.class)getConvertedValue(Object,Object,Class)@Nullable default BigInteger getAsBigInteger(@Nullable KEYTYPE aKey, @Nullable BigInteger aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,aDefault,BigInteger.class)getConvertedValue(Object,Object, Class)@Nullable default LocalDate getAsLocalDate(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,LocalDate.class)getConvertedValue(Object,Object,Class)@Nullable default LocalDate getAsLocalDate(@Nullable KEYTYPE aKey, @Nullable LocalDate aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,aDefault,LocalDate.class)getConvertedValue(Object,Object,Class)@Nullable default LocalTime getAsLocalTime(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,LocalTime.class)getConvertedValue(Object,Object,Class)@Nullable default LocalTime getAsLocalTime(@Nullable KEYTYPE aKey, @Nullable LocalTime aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,aDefault,LocalTime.class)getConvertedValue(Object,Object,Class)@Nullable default LocalDateTime getAsLocalDateTime(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,LocalDateTime.class)getConvertedValue(Object,Object,Class)@Nullable default LocalDateTime getAsLocalDateTime(@Nullable KEYTYPE aKey, @Nullable LocalDateTime aDefault)
aKey - The key to be accessed. May be null.aDefault - The value to be returned if the retrieved value is null
.getConvertedValue (aKey,aDefault,LocalDateTime.class)getConvertedValue(Object,Object,Class)@Nullable default byte[] getAsByteArray(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,byte[].class)getConvertedValue(Object,Object,Class)@Nullable default Boolean getAsBooleanObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Boolean.class)getConvertedValue(Object,Object,Class)@Nullable default Byte getAsByteObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Byte.class)getConvertedValue(Object,Object,Class)@Nullable default Character getAsCharObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Character.class)getConvertedValue(Object,Object,Class)@Nullable default Double getAsDoubleObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Double.class)getConvertedValue(Object,Object,Class)@Nullable default Float getAsFloatObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Float.class)getConvertedValue(Object,Object,Class)@Nullable default Integer getAsIntObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Integer.class)getConvertedValue(Object,Object,Class)@Nullable default Long getAsLongObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Long.class)getConvertedValue(Object,Object,Class)@Nullable default Short getAsShortObj(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Short.class)getConvertedValue(Object,Object,Class)@Nullable default Blob getAsSqlBlob(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Blob.class)getConvertedValue(Object,Object,Class)@Nullable default Clob getAsSqlClob(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Clob.class)getConvertedValue(Object,Object,Class)@Nullable default Date getAsSqlDate(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Date.class)getConvertedValue(Object,Object,Class)@Nullable default NClob getAsSqlNClob(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,NClob.class)getConvertedValue(Object,Object,Class)@Nullable default RowId getAsSqlRowId(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,RowId.class)getConvertedValue(Object,Object,Class)@Nullable default Time getAsSqlTime(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Time.class)getConvertedValue(Object,Object,Class)@Nullable default Timestamp getAsSqlTimestamp(@Nullable KEYTYPE aKey)
aKey - The key to be accessed. May be null.getConvertedValue (aKey,null,Timestamp.class)getConvertedValue(Object,Object,Class)@Nullable default LocalDate getAsLocalDate(@Nullable KEYTYPE aKey, @Nonnull Locale aContentLocale)
LocalDate.aKey - The key to check. May be null.aContentLocale - Locale to use for conversion.null if either the conversion to String or the parsing
of the String failed.@Nullable default LocalTime getAsLocalTime(@Nullable KEYTYPE aKey, @Nonnull Locale aContentLocale)
LocalTime.aKey - The key to check. May be null.aContentLocale - Locale to use for conversion.null if either the conversion to String or the parsing
of the String failed.@Nullable default LocalDateTime getAsLocalDateTime(@Nullable KEYTYPE aKey, @Nonnull Locale aContentLocale)
LocalDateTime.aKey - The key to check. May be null.aContentLocale - Locale to use for conversion.null if either the conversion to String or the parsing
of the String failed.@Nullable default ICommonsList<String> getAsStringList(@Nullable KEYTYPE aKey)
aKey - The key to check. May be null.null if no such attribute value exists@Nullable default ICommonsList<String> getAsStringList(@Nullable KEYTYPE aKey, @Nullable ICommonsList<String> aDefault)
aKey - The key to check. May be null.aDefault - The default value to be returned, if no such attribute is present.aDefault if no such attribute value exists@Nullable default ICommonsOrderedSet<String> getAsStringSet(@Nullable KEYTYPE aKey)
aKey - The key to check. May be null.null if no such attribute value exists@Nullable default ICommonsOrderedSet<String> getAsStringSet(@Nullable KEYTYPE aKey, @Nullable ICommonsOrderedSet<String> aDefault)
aKey - The key to check. May be null.aDefault - The default value to be returned, if no such attribute is present.aDefault if no such attribute value existsdefault boolean hasStringValue(@Nullable KEYTYPE aKey, @Nullable String sDesiredValue)
aKey - The key to check. May be null.sDesiredValue - The value to be matchedtrue if an attribute with the given name is present
and has the desired valuedefault boolean hasStringValue(@Nullable KEYTYPE aKey, @Nullable String sDesiredValue, boolean bDefault)
aKey - The key to check. May be null.sDesiredValue - The value to be matchedbDefault - the default value to be returned, if the specified attribute is not
presenttrue if an attribute with the given name is present
and has the desired value, false if the attribute is
present but has a different value. If the attribute is not present,
the default value is returned.Copyright © 2014–2020 Philip Helger. All rights reserved.