-
- All Superinterfaces:
MarshallableObject,Marshaller<Object>,Marshalling<Object>,MarshallingObject,ReadableBean,UnmarshallableObject,Unmarshaller<Object>,Validatable
- All Known Subinterfaces:
EntityBean,VirtualBean
- All Known Implementing Classes:
AbstractBean,AbstractVirtualBean,AdvancedBean,Bean,DynamicBean,SimpleEntityBean
public interface WritableBean extends ReadableBean, MarshallingObject
Writable interface ofReadableBean.
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.bean.ReadableBean
PROPERTY_TYPE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <P extends WritableProperty<?>>
PaddProperty(P property)Adds the givenWritablePropertyto this bean.default <V> WritableProperty<V>createProperty(String name, Class<V> valueClass)<V> WritableProperty<V>createProperty(String name, Class<V> valueClass, Type valueType)default <V> WritableProperty<V>getOrCreateProperty(String name, Class<V> valueClass)default <V> WritableProperty<V>getOrCreateProperty(String name, Class<V> valueClass, Type valueType)Iterable<? extends WritableProperty<?>>getProperties()WritableProperty<?>getProperty(String name)default WritableProperty<?>getRequiredProperty(String name)default voidread(StructuredReader reader)default voidset(String name, Object value)Sets the value of therequired propertywith the givennameto the given value.default <V> voidset(String name, V value, Class<V> valueClass)/** Sets the value of theexisting or newly created propertywith the givennameto the given value.default <V> voidset(String name, V value, Class<V> valueClass, Type valueType)/** Sets the value of theexisting or newly created propertywith the givennameto the given value.-
Methods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObject
-
Methods inherited from interface io.github.mmm.bean.ReadableBean
copy, copy, get, getPropertyCount, getPropertyNameForAlias, getType, isDynamic, isEqualTo, isPolymorphic, isPrototype, isReadOnly, newInstance, validate, write
-
Methods inherited from interface io.github.mmm.marshall.UnmarshallableObject
readObject
-
-
-
-
Method Detail
-
getProperty
WritableProperty<?> getProperty(String name)
- Specified by:
getPropertyin interfaceReadableBean- Parameters:
name- thenameof the requested property or a potentialaliasof the property.- Returns:
- the requested
WritablePropertyornullif no such property exists. - See Also:
addProperty(WritableProperty),getOrCreateProperty(String, Class)
-
getProperties
Iterable<? extends WritableProperty<?>> getProperties()
- Specified by:
getPropertiesin interfaceReadableBean- Returns:
- an
Iterableof all properties of this bean.
-
getRequiredProperty
default WritableProperty<?> getRequiredProperty(String name)
- Specified by:
getRequiredPropertyin interfaceReadableBean- Parameters:
name- thenameof the requested property.- Returns:
- the requested
property.
-
set
default void set(String name, Object value)
Sets the value of therequired propertywith the givennameto the given value.
-
set
default <V> void set(String name, V value, Class<V> valueClass)
/** Sets the value of theexisting or newly created propertywith the givennameto the given value.- Type Parameters:
V- the generic type of thevalue class.- Parameters:
name- theproperty name.value- newvalueof the specified property.valueClass- thevalue class.- See Also:
set(String, Object)
-
set
default <V> void set(String name, V value, Class<V> valueClass, Type valueType)
/** Sets the value of theexisting or newly created propertywith the givennameto the given value.- Type Parameters:
V- the generic type of thevalue class.- Parameters:
name- theproperty name.value- newvalueof the specified property.valueClass- thevalue class.valueType- theTypereflecting theproperty value.- See Also:
set(String, Object)
-
addProperty
<P extends WritableProperty<?>> P addProperty(P property)
Adds the givenWritablePropertyto this bean.- Type Parameters:
P- type of theWritablePropertyto add.- Parameters:
property- theWritablePropertyto add.- Returns:
- the given
property. - Throws:
IllegalStateException- if thisWritableBeanisread-onlyor notdynamic.
-
createProperty
default <V> WritableProperty<V> createProperty(String name, Class<V> valueClass)
- Type Parameters:
V- the generic type of thevalue class.- Parameters:
name- theproperty name.valueClass- thevalue class.- Returns:
- the newly created and added property.
- Throws:
IllegalStateException- if thisWritableBeanalready has such property, isread-only, or notdynamic.
-
createProperty
<V> WritableProperty<V> createProperty(String name, Class<V> valueClass, Type valueType)
- Type Parameters:
V- the generic type of thevalue class.- Parameters:
name- theproperty name.valueClass- thevalue class.valueType- theTypereflecting theproperty value.- Returns:
- the newly created and added property.
- Throws:
IllegalStateException- if thisWritableBeanalready has such property, isread-only, or notdynamic.
-
getOrCreateProperty
default <V> WritableProperty<V> getOrCreateProperty(String name, Class<V> valueClass)
- Type Parameters:
V- the generic type of theproperty value.- Parameters:
name- theproperty name.valueClass- thevalue classof the requested property.- Returns:
- the requested property. Will be created if it does not already
exist. - Throws:
IllegalArgumentException- if the requested property already exists but has an incompatiblevalue class.IllegalStateException- if the requested property does not exist but thisWritableBeanisread-only, or notdynamic.
-
getOrCreateProperty
default <V> WritableProperty<V> getOrCreateProperty(String name, Class<V> valueClass, Type valueType)
- Type Parameters:
V- the generic type of theproperty value.- Parameters:
name- theproperty name.valueClass- theClassreflecting theproperty value.valueType- theTypereflecting theproperty value.- Returns:
- the requested property. Will be created if it does not already
exist. - Throws:
IllegalArgumentException- if the requested property already exists but has an incompatiblevalue class.IllegalStateException- if the requested property does not exist but thisWritableBeanisread-only, or notdynamic.
-
read
default 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.
-
-