Package com.mayam.wf.attributes.shared
Class AttributeMap
java.lang.Object
com.mayam.wf.attributes.shared.AttributeMap
- All Implemented Interfaces:
AttributeManager
,AttributeMutator
,Copyable
,Navigable
Map from
Attribute
to value. When properly injected,
the map will validate input to make sure it conforms to
Attribute
annotations.
Setting an attribute will mark it as dirty.- Author:
- Markus MÃ¥rtensson
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Fluid export with optional filtering and merging instructions.static interface
Describes a class containing anAttributeMap
.Nested classes/interfaces inherited from interface com.mayam.wf.attributes.shared.Copyable
Copyable.Utilities
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
attachCache
(AttributeMap cache) Attaches a cache for use in scenarios where the AttributeMap describes a subject with operation parameters.void
clear()
Removes all values from the map.@NonNull AttributeMap
Clears the dirty flags on all attribute values within the map.boolean
containsAttribute
(Attribute attribute) @Nullable AttributeMap
Detaches the current cache, returning it.boolean
export()
Begins a fluid export.<T> @Nullable T
getAttribute
(Attribute attribute) Attribute accessor.<T> @Nullable T
getAttribute
(Attribute attribute, Class<T> cls) Attribute accessor.@Nullable String
getAttributeAsString
(Attribute attribute) Gets an attribute value, converted to a string.<T> @Nullable T
getAttributeByFieldId
(String fieldId) Attribute accessor based on field identifier.<T> @Nullable T
getAttributeByFieldId
(String fieldId, Class<T> cls) Attribute accessor based on field identifier.@Nullable String
getAttributeByFieldIdAsString
(String fieldId) Gets an attribute value based on field identifier, converted to a string.Compile a set of attributes with values inside this attribute map.Compile a set of attributes with dirty values inside this attribute map.boolean
hasCache()
int
hashCode()
boolean
Checks for the existence ofAttributeValidator
andAttributeDescription.Producer
helper instances.void
injectHelpers
(AttributeValidator validator, AttributeDescription.Producer describer, AttributeFieldMapper attributeFieldMapper) Injects helper objects.boolean
managesAttribute
(Attribute attribute) Determines if the given attribute is part of the subset managed by the class.static AttributeMap
merge
(AttributeMap original, AttributeMap overrides) Merges two AttributeMap objects with priority given to the one referred to as "overrides".Given a key relative to this object, returns the associated object if any.void
putAll
(AttributeMap source) Copy values from another attribute map into this, regardless of dirty status.void
putClean
(AttributeMap source) Copy values from another attribute map into this, unless they already exist in dirty state.void
putDirty
(AttributeMap source) Copy dirty values from another attribute map into this.void
removeAttribute
(Attribute attribute) Removes a value from the map.void
removeAttributeByFieldId
(String fieldId) Remove attribute based on field identifier.<T> @NonNull T
requireAttribute
(Attribute attribute) Attribute accessor with included null-check.<T> @NonNull T
requireAttribute
(Attribute attribute, Class<T> cls) Attribute accessor with included null-check.<T> @NonNull T
requireAttributeByFieldId
(String fieldId) Attribute accessor, based on field identifier, with included non-check.@NonNull AttributeMap
setAttribute
(Attribute attribute, Object value) Attribute mutator.@NonNull AttributeMap
setAttribute
(Attribute attribute, Object value, boolean markAsDirty) Attribute mutator with the option of disabling dirty flagging.@NonNull AttributeMap
setAttributeByFieldId
(String fieldId, Object value) Attribute mutator based on field identifier.@NonNull AttributeMap
setAttributeByFieldIdFromString
(String fieldId, String valueStr) Attribute mutator based on field identifier.@NonNull AttributeMap
setAttributeFromString
(Attribute attribute, String valueStr) Sets attribute value based on on a string, converting it to the class defined byDeclare.valueClass()
.@NonNull String
@NonNull String
toLongString
(String separator) @NonNull String
toLongString
(String separator, boolean ignoreNulls) @NonNull String
toLongString
(String separator, boolean ignoreNulls, boolean print_dirty) @NonNull String
@NonNull String
toLongStringIgnoreNulls
(String separator) @NonNull String
toString()
-
Constructor Details
-
AttributeMap
public AttributeMap()
-
-
Method Details
-
hasInjectedHelpers
public boolean hasInjectedHelpers()Checks for the existence ofAttributeValidator
andAttributeDescription.Producer
helper instances.- Returns:
- true if both helpers are injected.
-
clear
public void clear()Removes all values from the map. -
getAttributeByFieldId
Attribute accessor based on field identifier. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Type Parameters:
T
- the requested type for casting.- Parameters:
fieldId
- the field identifier.- Returns:
- the current value of the attribute, cast as requested.
-
getAttributeByFieldId
Attribute accessor based on field identifier. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Parameters:
fieldId
- the field identifier.cls
- the requested type for casting.- Returns:
- the current value of the attribute, cast as requested.
-
getAttributeByFieldIdAsString
Gets an attribute value based on field identifier, converted to a string. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Parameters:
fieldId
- the field id- Returns:
- attribute value converted to a string.
-
setAttributeByFieldId
Attribute mutator based on field identifier. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Parameters:
fieldId
- the field identifier.value
- the new value of the attribute.- Returns:
- the manager, to allow method chaining.
-
setAttributeByFieldIdFromString
Attribute mutator based on field identifier. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Parameters:
fieldId
- the field identifier.valueStr
- the string representation of the value to set.- Returns:
- the manager, to allow method chaining.
-
removeAttributeByFieldId
Remove attribute based on field identifier. Requires aAttributeFieldMapper
implementation, which is typically only bound on the server side.- Parameters:
fieldId
- the field identifier.
-
requireAttributeByFieldId
Attribute accessor, based on field identifier, with included non-check. Should the value value prove to be null, a exception is thrown.- Type Parameters:
T
- the requested type for casting.- Parameters:
fieldId
- the field identifier.- Returns:
- the current non-null value of the attribute, cast as requested.
- Throws:
IllegalArgumentException
- if the value is null.
-
getAttributeSet
Compile a set of attributes with values inside this attribute map.- Returns:
- attribute set.
-
getDirtySet
Compile a set of attributes with dirty values inside this attribute map.- Returns:
- dirty attribute set.
-
clearDirty
Clears the dirty flags on all attribute values within the map.- Returns:
- the map to allow method chaining.
-
detachCache
Detaches the current cache, returning it. -
hasCache
public boolean hasCache() -
hashCode
public int hashCode() -
equals
-
toLongString
-
toLongStringIgnoreNulls
-
toLongStringIgnoreNulls
-
toLongString
-
toLongString
-
toLongString
-
toString
-
export
Begins a fluid export.- See Also: