- 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>
-
- Type Parameters:
V- type of thevalue.
- All Implemented Interfaces:
EventSource<ObservableEvent<V>,ObservableEventListener<? super V>>,MarshallableObject,Marshaller<Object>,Marshalling<Object>,MarshallingObject,UnmarshallableObject,Unmarshaller<Object>,ReadableProperty<V>,WritableProperty<V>,Validatable,ObservableValue<V>,WritableObservableValue<V>,PropertyPath<V>,ReadableTypedValue<V>,ReadableValue<V>,TypedPropertyPath<V>,WritableValue<V>,Cloneable,Supplier<V>
- Direct Known Subclasses:
BeanProperty,ContainerProperty,SimpleProperty
public abstract class Property<V> extends AbstractWritableObservableValue<V> implements WritableProperty<V>, Cloneable
Implementation ofWritableProperty.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.property.WritableProperty
NO_PROPERTIES
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclearValidationResult()Clears the cached internalvalidationresult.protected Property<V>clone()Property<V>copy(String newName, PropertyMetadata<V> newMetadata)ValidationResultdoValidate(String source)protected ValidationResultdoValidate(V v, String source)Called fromvalidate()in case re-validation is required.booleanequals(Object obj)Vget()PropertyMetadata<V>getMetadata()StringgetName()WritableProperty<V>getReadOnly()inthashCode()booleanisReadOnly()booleanisValid()booleanisValueMutable()voidread(StructuredReader reader)Property<V>readObject(StructuredReader reader)ATTENTION: This object will be modified such that the read data will be applied.protected voidrequireWritable()protected voidsetWithChange(V oldValue, V value)Internal method called fromAbstractWritableObservableValue.set(Object)if the value actually changed.voidtoString(StringBuilder sb)ValidationResultvalidate()This method performs the actual validation.voidwrite(StructuredWriter writer)voidwriteObject(StructuredWriter writer, Object object)-
Methods inherited from class io.github.mmm.value.observable.AbstractWritableObservableValue
bindInternal, bindOneWay, bindTwoWay, doGet, doSet, isBoundOneWay, isValueEqual, 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.property.ReadableProperty
isTransient
-
Methods inherited from interface io.github.mmm.value.ReadableTypedValue
getValueClass
-
Methods inherited from interface io.github.mmm.value.ReadableValue
getSafe
-
Methods inherited from interface io.github.mmm.value.observable.WritableObservableValue
bindOneWay, bindTwoWay, isBoundOneWay, unbindOneWay, unbindTwoWay
-
Methods inherited from interface io.github.mmm.value.WritableValue
set
-
-
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getNamein interfacePropertyPath<V>- Specified by:
getNamein interfaceReadableProperty<V>- Returns:
- the name of the property. By convention it should start with a
capitalletter followed by alpha-numeric characters. The name of a single property must especially not contain the dot character (.) that is used to separate segments in apath.
-
getMetadata
public PropertyMetadata<V> getMetadata()
- Specified by:
getMetadatain interfaceReadableProperty<V>- Returns:
- the
metadataof this property.
-
copy
public final Property<V> copy(String newName, PropertyMetadata<V> newMetadata)
- Specified by:
copyin interfaceWritableProperty<V>- Parameters:
newName- the newname. May benullto keep the current name.newMetadata- the newmetadata. May benullto keep the current metadata.- Returns:
- a new instance of this property with empty
valueno bindings and the given parameters applied.
-
get
public V get()
- Specified by:
getin interfaceReadableValue<V>- Specified by:
getin interfaceSupplier<V>- Overrides:
getin classAbstractWritableObservableValue<V>- Returns:
- the current value of this object. May be
nullunless otherwise stated.
-
setWithChange
protected void setWithChange(V oldValue, V value)
Description copied from class:AbstractWritableObservableValueInternal method called fromAbstractWritableObservableValue.set(Object)if the value actually changed.- Overrides:
setWithChangein classAbstractWritableObservableValue<V>- Parameters:
oldValue- the old value.value- the new value.
-
requireWritable
protected final void requireWritable() throws IllegalStateException- Overrides:
requireWritablein classAbstractWritableObservableValue<V>- Throws:
IllegalStateException- if this property is not writable.
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceReadableProperty<V>- Returns:
trueif valid,falseotherwise.- See Also:
Validatable.validate()
-
clearValidationResult
protected void clearValidationResult()
Clears the cached internalvalidationresult. Has to be called if thevaluehas changed (from an external call) and is notmutable.
-
validate
public final ValidationResult validate()
Description copied from interface:ValidatableThis method performs the actual validation.- Specified by:
validatein interfaceValidatable- Returns:
ValidationResultthe validation failure.- See Also:
Validator.validate(Object)
-
doValidate
public ValidationResult doValidate(String source)
- Parameters:
source- thevalidation source.- Returns:
- the
result of the validation. - See Also:
validate()
-
doValidate
protected ValidationResult doValidate(V v, String source)
Called fromvalidate()in case re-validation is required.- Parameters:
v- thevalueto validate.source- thevalidation source.- Returns:
- the
result of the validation.
-
isValueMutable
public boolean isValueMutable()
- Returns:
trueif thevalue typeof this property is mutable (e.g.CollectionorMap),falseotherwise (immutable datatype such asString,Boolean,Number,Temporal, etc.).
-
getReadOnly
public WritableProperty<V> getReadOnly()
- Specified by:
getReadOnlyin interfaceWritableProperty<V>- Returns:
- the
read onlyview on this property. - See Also:
ReadableProperty.isReadOnly(),WritableProperty.getReadOnly(WritableProperty)
-
isReadOnly
public final boolean isReadOnly()
- Specified by:
isReadOnlyin interfaceReadableProperty<V>- Returns:
trueif this property is immutable (read-only) andmodificationswill fail with an exception,falseotherwise.- See Also:
WritableProperty.getReadOnly()
-
toString
public void toString(StringBuilder sb)
- Specified by:
toStringin interfaceObservableValue<V>- Overrides:
toStringin classAbstractObservableValue<V>- Parameters:
sb- theStringBuilderwhere to append the details of this property forAbstractObservableValue.toString()-Representation.
-
writeObject
public final void writeObject(StructuredWriter writer, Object object)
- Specified by:
writeObjectin interfaceMarshallableObject- Specified by:
writeObjectin interfaceMarshaller<V>- Parameters:
writer- theStructuredWriterwhere to write the data of the givenobjectto. Create via e.g.JsonFormat.get().writer(writer)orXmlFormat.get().writer(writer).object- the object to serialize or marshall. If this is an instance ofMarshallableObjectthen this has to be the called instance itself.
-
write
public void write(StructuredWriter writer)
- Specified by:
writein interfaceMarshallableObject- Parameters:
writer- theStructuredWriterwhere to marshall (serialize) the data of this object to.- See Also:
MarshallableObject.writeObject(StructuredWriter, Object)
-
readObject
public final Property<V> readObject(StructuredReader reader)
Description copied from interface:UnmarshallableObjectATTENTION: 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.- Specified by:
readObjectin interfaceUnmarshallableObject- Specified by:
readObjectin interfaceUnmarshaller<V>- Parameters:
reader- theStructuredReaderwhere to read the data from.- Returns:
- the unmarhsalled or de-serialized object. If this is an instance of
UnmarshallableObjectthen the called instance is modified by filling in the unmarshalled data and will return itself. - See Also:
UnmarshallableObject.read(StructuredReader)
-
read
public void read(StructuredReader reader)
- Specified by:
readin interfaceUnmarshallableObject- 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.
-
-