- 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 void
clearValidationResult()
Clears the cached internalvalidation
result.protected Property<V>
clone()
Property<V>
copy(String newName, PropertyMetadata<V> newMetadata)
ValidationResult
doValidate(String source)
protected ValidationResult
doValidate(V v, String source)
Called fromvalidate()
in case re-validation is required.boolean
equals(Object obj)
V
get()
PropertyMetadata<V>
getMetadata()
String
getName()
WritableProperty<V>
getReadOnly()
int
hashCode()
boolean
isReadOnly()
boolean
isValid()
boolean
isValueMutable()
void
read(StructuredReader reader)
Property<V>
readObject(StructuredReader reader)
ATTENTION: This object will be modified such that the read data will be applied.protected void
requireWritable()
protected void
setWithChange(V oldValue, V value)
Internal method called fromAbstractWritableObservableValue.set(Object)
if the value actually changed.void
toString(StringBuilder sb)
ValidationResult
validate()
This method performs the actual validation.void
write(StructuredWriter writer)
void
writeObject(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:
getName
in interfacePropertyPath<V>
- Specified by:
getName
in interfaceReadableProperty<V>
- Returns:
- the name of the property. By convention it should start with a
capital
letter 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:
getMetadata
in interfaceReadableProperty<V>
- Returns:
- the
metadata
of this property.
-
copy
public final Property<V> copy(String newName, PropertyMetadata<V> newMetadata)
- Specified by:
copy
in interfaceWritableProperty<V>
- Parameters:
newName
- the newname
. May benull
to keep the current name.newMetadata
- the newmetadata
. May benull
to keep the current metadata.- Returns:
- a new instance of this property with empty
value
no bindings and the given parameters applied.
-
get
public V get()
- Specified by:
get
in interfaceReadableValue<V>
- Specified by:
get
in interfaceSupplier<V>
- Overrides:
get
in classAbstractWritableObservableValue<V>
- Returns:
- the current value of this object. May be
null
unless otherwise stated.
-
setWithChange
protected void setWithChange(V oldValue, V value)
Description copied from class:AbstractWritableObservableValue
Internal method called fromAbstractWritableObservableValue.set(Object)
if the value actually changed.- Overrides:
setWithChange
in classAbstractWritableObservableValue<V>
- Parameters:
oldValue
- the old value.value
- the new value.
-
requireWritable
protected final void requireWritable() throws IllegalStateException
- Overrides:
requireWritable
in classAbstractWritableObservableValue<V>
- Throws:
IllegalStateException
- if this property is not writable.
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceReadableProperty<V>
- Returns:
true
if valid,false
otherwise.- See Also:
Validatable.validate()
-
clearValidationResult
protected void clearValidationResult()
Clears the cached internalvalidation
result. Has to be called if thevalue
has changed (from an external call) and is notmutable
.
-
validate
public final ValidationResult validate()
Description copied from interface:Validatable
This method performs the actual validation.- Specified by:
validate
in interfaceValidatable
- Returns:
ValidationResult
the 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
- thevalue
to validate.source
- thevalidation source
.- Returns:
- the
result of the validation
.
-
isValueMutable
public boolean isValueMutable()
- Returns:
true
if thevalue type
of this property is mutable (e.g.Collection
orMap
),false
otherwise (immutable datatype such asString
,Boolean
,Number
,Temporal
, etc.).
-
getReadOnly
public WritableProperty<V> getReadOnly()
- Specified by:
getReadOnly
in interfaceWritableProperty<V>
- Returns:
- the
read only
view on this property. - See Also:
ReadableProperty.isReadOnly()
,WritableProperty.getReadOnly(WritableProperty)
-
isReadOnly
public final boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceReadableProperty<V>
- Returns:
true
if this property is immutable (read-only) andmodifications
will fail with an exception,false
otherwise.- See Also:
WritableProperty.getReadOnly()
-
toString
public void toString(StringBuilder sb)
- Specified by:
toString
in interfaceObservableValue<V>
- Overrides:
toString
in classAbstractObservableValue<V>
- Parameters:
sb
- theStringBuilder
where to append the details of this property forAbstractObservableValue.toString()
-Representation.
-
writeObject
public final void writeObject(StructuredWriter writer, Object object)
- Specified by:
writeObject
in interfaceMarshallableObject
- Specified by:
writeObject
in interfaceMarshaller<V>
- Parameters:
writer
- theStructuredWriter
where to write the data of the givenobject
to. Create via e.g.JsonFormat.get().writer(writer)
orXmlFormat.get().writer(writer)
.object
- the object to serialize or marshall. If this is an instance ofMarshallableObject
then this has to be the called instance itself.
-
write
public void write(StructuredWriter writer)
- Specified by:
write
in interfaceMarshallableObject
- Parameters:
writer
- theStructuredWriter
where 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:UnmarshallableObject
ATTENTION: 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:
readObject
in interfaceUnmarshallableObject
- Specified by:
readObject
in interfaceUnmarshaller<V>
- Parameters:
reader
- theStructuredReader
where to read the data from.- Returns:
- the unmarhsalled or de-serialized object. If this is an instance of
UnmarshallableObject
then 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:
read
in interfaceUnmarshallableObject
- Parameters:
reader
- theStructuredReader
where 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.
-
-