- java.lang.Object
-
- io.github.mmm.event.AbstractEventSource<ObservableEvent<V>,ObservableEventListener<? super V>>
-
- io.github.mmm.value.observable.AbstractObservableValue<V>
-
- io.github.mmm.value.observable.AbstractWritableObservableValue<V>
-
- io.github.mmm.property.Property<V>
-
- io.github.mmm.property.container.ContainerProperty<Map<K,V>,V>
-
- io.github.mmm.property.container.map.MapProperty<K,V>
-
- All Implemented Interfaces:
EventSource<ObservableEvent<Map<K,V>>,ObservableEventListener<? super Map<K,V>>>,MarshallableObject,Marshaller<Object>,Marshalling<Object>,MarshallingObject,UnmarshallableObject,Unmarshaller<Object>,ReadableMapProperty<K,V>,WritableMapProperty<K,V>,ReadableContainerProperty<Map<K,V>,V>,WritableContainerProperty<Map<K,V>,V>,ReadableProperty<Map<K,V>>,WritableProperty<Map<K,V>>,Validatable,ObservableMapValue<K,V>,ReadableMapValue<K,V>,WritableMapValue<K,V>,ObservableContainerValue<Map<K,V>,V>,ReadableContainerValue<Map<K,V>,V>,WritableContainerValue<Map<K,V>,V>,ReadableObjectValue<Map<K,V>>,ReadableTypedObjectValue<Map<K,V>>,WritableObjectValue<Map<K,V>>,ObservableValue<Map<K,V>>,WritableObservableValue<Map<K,V>>,PropertyPath<Map<K,V>>,ReadableTypedValue<Map<K,V>>,ReadableValue<Map<K,V>>,TypedPropertyPath<Map<K,V>>,WritableValue<Map<K,V>>,Cloneable,Supplier<Map<K,V>>
public class MapProperty<K,V> extends ContainerProperty<Map<K,V>,V> implements WritableMapProperty<K,V>
Implementation ofWritableMapProperty.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from class io.github.mmm.property.container.ContainerProperty
valueProperty
-
Fields inherited from interface io.github.mmm.property.container.ReadableContainerProperty
METADATA_KEY_COMPONENT_PROPERTY
-
Fields inherited from interface io.github.mmm.property.container.map.ReadableMapProperty
METADATA_KEY_KEY_PROPERTY
-
Fields inherited from interface io.github.mmm.property.WritableProperty
NO_PROPERTIES
-
-
Constructor Summary
Constructors Constructor Description MapProperty(String name, SimpleProperty<K> keyProperty, Property<V> valueProperty)The constructor.MapProperty(String name, SimpleProperty<K> keyProperty, Property<V> valueProperty, PropertyMetadata<Map<K,V>> metadata)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<K,V>doGet()protected voiddoSet(Map<K,V> newValue)protected ValidationResultdoValidate(Map<K,V> map, String source)Called fromProperty.validate()in case re-validation is required.ChangeAwareMap<K,V>getChangeAwareValue()SimpleProperty<K>getKeyProperty()booleanisChangeAware()voidread(StructuredReader reader)voidwrite(StructuredWriter writer)protected voidwriteKey(StructuredWriter writer, K key)Implementation ofwrite(StructuredWriter)for amap key.protected voidwriteValue(StructuredWriter writer, V mapValue)Implementation ofwrite(StructuredWriter)for amap value.-
Methods inherited from class io.github.mmm.property.container.ContainerProperty
emptyProperty, getValueProperty, invalidateProperties, isValueEqual, isValueMutable, sizeProperty
-
Methods inherited from class io.github.mmm.property.Property
clearValidationResult, clone, copy, doValidate, equals, get, getMetadata, getName, getReadOnly, hashCode, isReadOnly, isValid, readObject, requireWritable, setWithChange, toString, validate, writeObject
-
Methods inherited from class io.github.mmm.value.observable.AbstractWritableObservableValue
bindInternal, bindOneWay, bindTwoWay, isBoundOneWay, set, unbindOneWay, unbindTwoWay
-
Methods inherited from class io.github.mmm.value.observable.AbstractObservableValue
addListener, fireChange, fireEvent, fireEvent, fireEventFor, fireEventFor, fireEventWithOldValue, hasChangeAwareListeners, invalidate, removeListener, toString
-
Methods inherited from class io.github.mmm.event.AbstractEventSource
getEventAdapter, hasListeners
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.event.EventSource
addListener, addListener, addWeakListener, removeListener
-
Methods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObject
-
Methods inherited from interface io.github.mmm.value.observable.ObservableValue
toString
-
Methods inherited from interface io.github.mmm.property.container.ReadableContainerProperty
emptyProperty, sizeProperty
-
Methods inherited from interface io.github.mmm.value.observable.container.ReadableContainerValue
isEmpty
-
Methods inherited from interface io.github.mmm.value.observable.container.map.ReadableMapValue
getValueClass, size
-
Methods inherited from interface io.github.mmm.value.observable.object.ReadableObjectValue
getSafe, getValue
-
Methods inherited from interface io.github.mmm.property.ReadableProperty
getMetadata, getName, isReadOnly, isTransient, isValid
-
Methods inherited from interface io.github.mmm.value.ReadableValue
get
-
Methods inherited from interface io.github.mmm.marshall.UnmarshallableObject
readObject
-
Methods inherited from interface io.github.mmm.validation.Validatable
validate
-
Methods inherited from interface io.github.mmm.property.container.WritableContainerProperty
getValueProperty
-
Methods inherited from interface io.github.mmm.value.observable.container.map.WritableMapValue
getOrCreate
-
Methods inherited from interface io.github.mmm.value.observable.object.WritableObjectValue
setValue
-
Methods inherited from interface io.github.mmm.value.observable.WritableObservableValue
bindOneWay, bindTwoWay, isBoundOneWay, unbindOneWay, unbindTwoWay
-
Methods inherited from interface io.github.mmm.property.WritableProperty
copy, getReadOnly
-
Methods inherited from interface io.github.mmm.value.WritableValue
set
-
-
-
-
Constructor Detail
-
MapProperty
public MapProperty(String name, SimpleProperty<K> keyProperty, Property<V> valueProperty)
The constructor.- Parameters:
name- thename.keyProperty- thekey property.valueProperty- thevalue property.
-
MapProperty
public MapProperty(String name, SimpleProperty<K> keyProperty, Property<V> valueProperty, PropertyMetadata<Map<K,V>> metadata)
The constructor.- Parameters:
name- thename.keyProperty- thekey property.valueProperty- thevalue property.metadata- themetadata.
-
-
Method Detail
-
getKeyProperty
public SimpleProperty<K> getKeyProperty()
- Specified by:
getKeyPropertyin interfaceReadableMapProperty<K,V>- Returns:
- the
ReadablePropertyrepresenting the type of thekeysof theMapvalue.
-
doSet
protected void doSet(Map<K,V> newValue)
- Specified by:
doSetin classAbstractWritableObservableValue<Map<K,V>>- Parameters:
newValue- the newvalueto set.- See Also:
AbstractWritableObservableValue.set(Object)
-
doValidate
protected ValidationResult doValidate(Map<K,V> map, String source)
Description copied from class:PropertyCalled fromProperty.validate()in case re-validation is required.- Overrides:
doValidatein classProperty<Map<K,V>>- Parameters:
map- thevalueto validate.source- thevalidation source.- Returns:
- the
result of the validation.
-
isChangeAware
public boolean isChangeAware()
- Specified by:
isChangeAwarein interfaceWritableContainerProperty<K,V>- Returns:
trueifchange aware valuehas been initialized,falseotherwise.
-
getChangeAwareValue
public ChangeAwareMap<K,V> getChangeAwareValue()
- Specified by:
getChangeAwareValuein interfaceWritableContainerProperty<K,V>- Specified by:
getChangeAwareValuein interfaceWritableMapProperty<K,V>- Returns:
- the
valueasChangeAwareContainer. Will be initialized on the first call of this method. Unlessinitialized, a container property is lightweight just as other regular properties. Once this method was called, theChangeAwareContaineris initialized and triggers change events for modifications of the container instance itself. Calls toWritableValue.set(Object)will implicitly change thisChangeAwareContainersuch that in only contains what the provided new value contains. The instance of theChangeAwareContainerreturned by this method always remains the same.
-
read
public void read(StructuredReader reader)
- Specified by:
readin interfaceUnmarshallableObject- Overrides:
readin classProperty<Map<K,V>>- Parameters:
reader- theStructuredReaderwhere to read the data from. This object will be modified such that the read data will be applied. For complex objects (e.g. beans with multiple properties) those properties not defined in the data that is read will not be overwritten. In order to get a clean representation of the data from the given reader you should invoke this method on an empty object.
-
write
public void write(StructuredWriter writer)
- Specified by:
writein interfaceMarshallableObject- Overrides:
writein classProperty<Map<K,V>>- Parameters:
writer- theStructuredWriterwhere to marshall (serialize) the data of this object to.- See Also:
MarshallableObject.writeObject(StructuredWriter, Object)
-
writeKey
protected void writeKey(StructuredWriter writer, K key)
Implementation ofwrite(StructuredWriter)for amap key.- Parameters:
writer- theStructuredWriter.key- themap keyto marshall.
-
writeValue
protected void writeValue(StructuredWriter writer, V mapValue)
Implementation ofwrite(StructuredWriter)for amap value.- Parameters:
writer- theStructuredWriter.mapValue- themap valueto marshall.
-
-