-
- 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 givenWritableProperty
to 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 void
read(StructuredReader reader)
default void
set(String name, Object value)
Sets the value of therequired property
with the givenname
to the given value.default <V> void
set(String name, V value, Class<V> valueClass)
/** Sets the value of theexisting or newly created property
with the givenname
to the given value.default <V> void
set(String name, V value, Class<V> valueClass, Type valueType)
/** Sets the value of theexisting or newly created property
with the givenname
to 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:
getProperty
in interfaceReadableBean
- Parameters:
name
- thename
of the requested property or a potentialalias
of the property.- Returns:
- the requested
WritableProperty
ornull
if no such property exists. - See Also:
addProperty(WritableProperty)
,getOrCreateProperty(String, Class)
-
getProperties
Iterable<? extends WritableProperty<?>> getProperties()
- Specified by:
getProperties
in interfaceReadableBean
- Returns:
- an
Iterable
of all properties of this bean.
-
getRequiredProperty
default WritableProperty<?> getRequiredProperty(String name)
- Specified by:
getRequiredProperty
in interfaceReadableBean
- Parameters:
name
- thename
of the requested property.- Returns:
- the requested
property
.
-
set
default void set(String name, Object value)
Sets the value of therequired property
with the givenname
to the given value.
-
set
default <V> void set(String name, V value, Class<V> valueClass)
/** Sets the value of theexisting or newly created property
with the givenname
to the given value.- Type Parameters:
V
- the generic type of thevalue class
.- Parameters:
name
- theproperty name
.value
- newvalue
of 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 property
with the givenname
to the given value.- Type Parameters:
V
- the generic type of thevalue class
.- Parameters:
name
- theproperty name
.value
- newvalue
of the specified property.valueClass
- thevalue class
.valueType
- theType
reflecting theproperty value
.- See Also:
set(String, Object)
-
addProperty
<P extends WritableProperty<?>> P addProperty(P property)
Adds the givenWritableProperty
to this bean.- Type Parameters:
P
- type of theWritableProperty
to add.- Parameters:
property
- theWritableProperty
to add.- Returns:
- the given
property
. - Throws:
IllegalStateException
- if thisWritableBean
isread-only
or 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 thisWritableBean
already 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
- theType
reflecting theproperty value
.- Returns:
- the newly created and added property.
- Throws:
IllegalStateException
- if thisWritableBean
already 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 class
of 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 thisWritableBean
isread-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
- theClass
reflecting theproperty value
.valueType
- theType
reflecting 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 thisWritableBean
isread-only
, or notdynamic
.
-
read
default 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.
-
-