Interface IAttributeContainer<KEYTYPE,VALUETYPE>
-
- Type Parameters:
KEYTYPE- Key typeVALUETYPE- Value type
- All Superinterfaces:
ICloneable<ICommonsMap<KEYTYPE,VALUETYPE>>,ICommonsMap<KEYTYPE,VALUETYPE>,IGetterByKeyTrait<KEYTYPE>,Map<KEYTYPE,VALUETYPE>
- All Known Subinterfaces:
IAttributeContainerAny<KEYTYPE>,IStringMap
- All Known Implementing Classes:
AttributeContainer,AttributeContainerAny,AttributeContainerAnyConcurrent,AttributeContainerConcurrent,StringMap
public interface IAttributeContainer<KEYTYPE,VALUETYPE> extends ICommonsMap<KEYTYPE,VALUETYPE>, IGetterByKeyTrait<KEYTYPE>
Base interface for a generic read-only attribute container. It maps keys to values.
Note: don't implementIterable<Map.Entry<...>>because this would make the object ambiguous to e.g.HashCodeGenerator- Author:
- Philip Helger
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIAttributeContainer.IAfterSetValueCallback<KEYTYPE,VALUETYPE>static interfaceIAttributeContainer.IBeforeSetValueCallback<KEYTYPE,VALUETYPE>
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CallbackList<IAttributeContainer.IAfterSetValueCallback<KEYTYPE,VALUETYPE>>afterSetValueCallbacks()CallbackList<IAttributeContainer.IBeforeSetValueCallback<KEYTYPE,VALUETYPE>>beforeSetValueCallbacks()default booleangetAsBoolean(KEYTYPE aName)Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.default doublegetAsDouble(KEYTYPE aName)Get the attribute value associated to the given attribute name.default floatgetAsFloat(KEYTYPE aName)Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.default intgetAsInt(KEYTYPE aName)Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.default longgetAsLong(KEYTYPE aName)Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.IAttributeContainer<KEYTYPE,VALUETYPE>getClone()default VALUETYPEgetValue(KEYTYPE aName)Get the attribute value associated to the given attribute name.default EChangeputAllIn(Map<? extends KEYTYPE,? extends VALUETYPE> aAttrs)default EChangeputIn(KEYTYPE aName, VALUETYPE aNewValue)Set/overwrite an attribute value including before and after callbacks.-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsMap
addAll, containsAnyEntry, containsAnyKey, containsAnyValue, copyOfEntrySet, copyOfKeySet, copyOfKeySet, copyOfValues, copyOfValues, copyOfValuesMapped, copyOfValuesMapped, createInstance, findFirstEntry, findFirstKey, findFirstValue, forEach, forEachKey, forEachKey, forEachValue, forEachValue, getAsUnmodifiable, getFirstEntry, getFirstEntry, getFirstKey, getFirstKey, getFirstValue, getFirstValue, getSortedByKey, getSortedByValue, getSwappedKeyValues, isNotEmpty, put, putAll, putAll, putAllMapped, putAllMapped, putAllMapped, putIf, putIfNotNull, removeAll, removeIf, removeIfKey, removeIfValue, removeObject, setAll
-
Methods inherited from interface com.helger.commons.traits.IGetterByKeyTrait
containsNonNullValue, containsNullValue, getAsBigDecimal, getAsBigDecimal, getAsBigInteger, getAsBigInteger, getAsBoolean, getAsBooleanObj, getAsByte, getAsByte, getAsByteArray, getAsByteObj, getAsChar, getAsChar, getAsCharArray, getAsCharArray, getAsCharObj, getAsDouble, getAsDoubleObj, getAsFloat, getAsFloatObj, getAsInt, getAsIntObj, getAsLocalDate, getAsLocalDate, getAsLocalDate, getAsLocalDateTime, getAsLocalDateTime, getAsLocalDateTime, getAsLocalTime, getAsLocalTime, getAsLocalTime, getAsLong, getAsLongObj, getAsShort, getAsShort, getAsShortObj, getAsSqlBlob, getAsSqlClob, getAsSqlDate, getAsSqlNClob, getAsSqlRowId, getAsSqlTime, getAsSqlTimestamp, getAsString, getAsString, getAsStringList, getAsStringList, getAsStringSet, getAsStringSet, getCastedValue, getCastedValue, getCastedValue, getCastedValue, getConvertedValue, getConvertedValue, getSafeCastedValue, getSafeCastedValue, getValueClass, hasStringValue, hasStringValue, onSafeCastError
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
getValue
@Nullable default VALUETYPE getValue(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.- Specified by:
getValuein interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
nullif no such value exists
-
getAsInt
default int getAsInt(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.- Specified by:
getAsIntin interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
- The attribute value or
CGlobal.ILLEGAL_UINTif no such attribute exists
-
getAsLong
default long getAsLong(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.- Specified by:
getAsLongin interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
- The attribute value or
CGlobal.ILLEGAL_ULONGif no such attribute exists
-
getAsFloat
default float getAsFloat(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.- Specified by:
getAsFloatin interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
- The attribute value or
CGlobal.ILLEGAL_UINTif no such attribute exists
-
getAsDouble
default double getAsDouble(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.- Specified by:
getAsDoublein interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
- The attribute value or
CGlobal.ILLEGAL_UINTif no such attribute exists
-
getAsBoolean
default boolean getAsBoolean(@Nullable KEYTYPE aName)
Get the attribute value associated to the given attribute name.
Avoid throwing TypeConverterException by providing a default value.- Specified by:
getAsBooleanin interfaceIGetterByKeyTrait<KEYTYPE>- Parameters:
aName- the attribute name- Returns:
- The attribute value or
falseif no such attribute exists
-
beforeSetValueCallbacks
@Nonnull @ReturnsMutableObject CallbackList<IAttributeContainer.IBeforeSetValueCallback<KEYTYPE,VALUETYPE>> beforeSetValueCallbacks()
- Returns:
- Callbacks to be invoked before values are set. May not be
null.
-
afterSetValueCallbacks
@Nonnull @ReturnsMutableObject CallbackList<IAttributeContainer.IAfterSetValueCallback<KEYTYPE,VALUETYPE>> afterSetValueCallbacks()
- Returns:
- Callbacks to be invoked after values are set. May not be
null.
-
putIn
@Nonnull default EChange putIn(@Nonnull KEYTYPE aName, @Nullable VALUETYPE aNewValue)
Set/overwrite an attribute value including before and after callbacks.- Parameters:
aName- The name of the attribute. May not benull.aNewValue- The new value of the attribute. May benull.- Returns:
EChange.CHANGEDif something changed,EChange.UNCHANGEDotherwise.- See Also:
beforeSetValueCallbacks(),afterSetValueCallbacks(),ICommonsMap.removeObject(Object)
-
putAllIn
@Nonnull default EChange putAllIn(@Nullable Map<? extends KEYTYPE,? extends VALUETYPE> aAttrs)
-
getClone
@Nonnull @ReturnsMutableCopy IAttributeContainer<KEYTYPE,VALUETYPE> getClone()
- Specified by:
getClonein interfaceICloneable<KEYTYPE>- Returns:
- A 100% deep-copy of the implementing class.
-
-