- All Superinterfaces:
AttributeReadOnly
,io.github.mmm.marshall.MarshallableObject
,io.github.mmm.marshall.Marshaller<Object>
,io.github.mmm.marshall.Marshalling<Object>
,io.github.mmm.marshall.MarshallingObject
,ReadableBean
,io.github.mmm.value.ReadablePath
,io.github.mmm.marshall.id.StructuredIdMappingObject
,io.github.mmm.marshall.UnmarshallableObject
,io.github.mmm.marshall.Unmarshaller<Object>
,io.github.mmm.validation.Validatable
,io.github.mmm.value.WritablePath
- All Known Subinterfaces:
VirtualBean
- All Known Implementing Classes:
AbstractBean
,AbstractVirtualBean
,AdvancedBean
,Bean
,BeanAccessor
,DynamicBean
@AbstractInterface
public interface WritableBean
extends ReadableBean, io.github.mmm.value.WritablePath, io.github.mmm.marshall.MarshallingObject, io.github.mmm.marshall.id.StructuredIdMappingObject
Writable interface of
ReadableBean
.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.mmm.value.ReadablePath
io.github.mmm.value.ReadablePath.PathBuilder
-
Field Summary
Fields inherited from interface io.github.mmm.bean.ReadableBean
SUFFIX_PROPERTY
-
Method Summary
Modifier and TypeMethodDescription<P extends WritableProperty<?>>
PaddProperty
(P property) Adds the givenWritableProperty
to this bean.default Object
<V> WritableProperty
<V> createProperty
(String name, Class<V> valueClass) default io.github.mmm.marshall.id.StructuredIdMapping
static <B extends WritableBean>
Bfrom
(WritableProperty<?> property) default <V> WritableProperty
<V> getOrCreateProperty
(String name, Class<V> valueClass) Collection
<? extends WritableProperty<?>> getProperty
(String name) default WritableProperty
<?> getRequiredProperty
(String name) getType()
void
pathSegment
(String pathSegment) Used to set an alias as described inpathSegment()
.default WritableBean
read
(io.github.mmm.marshall.StructuredReader reader) static <B extends WritableBean>
List<B> readArray
(B template, io.github.mmm.marshall.StructuredReader reader) static <B extends WritableBean>
voidreadArray
(B template, io.github.mmm.marshall.StructuredReader reader, Collection<B> collection) default void
default <V> void
/** Sets the value of theexisting or newly created property
with the givenname
to the givenvalue
.default void
setDynamic
(String name, Object value) default void
write
(io.github.mmm.marshall.StructuredWriter writer) static <B extends WritableBean>
voidwriteArray
(Collection<B> beans, io.github.mmm.marshall.StructuredWriter writer) Methods inherited from interface io.github.mmm.property.AttributeReadOnly
isReadOnly
Methods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObject
Methods inherited from interface io.github.mmm.bean.ReadableBean
copy, doEquals, doToString, get, getAliases, getJavaClass, getPropertyCount, isDynamic, isEqual, isPolymorphic, isPrototype, mapPropertyIds, newInstance, toString, validate
Methods inherited from interface io.github.mmm.value.ReadablePath
parentPath, path, path, path
Methods inherited from interface io.github.mmm.marshall.UnmarshallableObject
readObject
Methods inherited from interface io.github.mmm.validation.Validatable
validateOrThrow
Methods inherited from interface io.github.mmm.value.WritablePath
parentPath
-
Method Details
-
getProperty
- 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:
-
getProperties
Collection<? extends WritableProperty<?>> getProperties()- Specified by:
getProperties
in interfaceReadableBean
- Returns:
- a
Collection
with allproperties
of this bean.
-
getRequiredProperty
- Specified by:
getRequiredProperty
in interfaceReadableBean
- Parameters:
name
- thename
of the requested property.- Returns:
- the requested
property
.
-
set
- Parameters:
name
- thename
of the property.value
- newvalue
of the specified property.
-
setDynamic
Sets the value of theproperty
with the givenname
to the givenvalue
. If no suchproperty
exists, it will becreated
dynamically
if the given value is notnull
.- Parameters:
name
- thename
of the property.value
- newvalue
of the specified property.
-
set
/** Sets the value of theexisting or newly created property
with the givenname
to the givenvalue
.- Type Parameters:
V
- the generic type of thevalue class
.- Parameters:
name
- theproperty name
.value
- newvalue
of the specified property.valueClass
- thevalue class
.- See Also:
-
addProperty
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
- 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
.
-
getOrCreateProperty
- 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
.
-
getType
BeanType getType()- Specified by:
getType
in interfaceReadableBean
- Returns:
- the
BeanType
reflecting thisBean
. - See Also:
-
read
- Specified by:
read
in interfaceio.github.mmm.marshall.UnmarshallableObject
-
write
default void write(io.github.mmm.marshall.StructuredWriter writer) - Specified by:
write
in interfaceio.github.mmm.marshall.MarshallableObject
-
defineIdMapping
default io.github.mmm.marshall.id.StructuredIdMapping defineIdMapping()- Specified by:
defineIdMapping
in interfaceio.github.mmm.marshall.id.StructuredIdMappingObject
-
asTypeKey
- Specified by:
asTypeKey
in interfaceio.github.mmm.marshall.id.StructuredIdMappingObject
-
pathSegment
String pathSegment()- Specified by:
pathSegment
in interfaceio.github.mmm.value.ReadablePath
- Returns:
- the optional alias of this bean. It will be appended as prefix to the
ReadablePath.path()
of allproperties
. This is useful for API to build queries. So e.g. set to "alias" and your contained property will have the path "alias.MyProperty".
-
pathSegment
Used to set an alias as described inpathSegment()
. ATTENTION: End users should never use this method directly but use designated methods such asas(String alias)
provided by according SQL clauses.- Specified by:
pathSegment
in interfaceio.github.mmm.value.WritablePath
-
from
- Type Parameters:
B
- type of theWritableBean
owning theproperty
.- Parameters:
property
- theWritableProperty
for which the owningWritableBean
is requested.- Returns:
- the
WritableBean
owning the givenproperty
. Will benull
if theWritableProperty
is manually created from outside a bean.
-
readArray
static <B extends WritableBean> List<B> readArray(B template, io.github.mmm.marshall.StructuredReader reader) - Type Parameters:
B
- type of theWritableBean
to read.- Parameters:
template
- an instance of theWritableBean
to read acting as template.reader
- theStructuredReader
to read the data from.- Returns:
- the
List
with the the unmarshalledbeans
.
-
readArray
static <B extends WritableBean> void readArray(B template, io.github.mmm.marshall.StructuredReader reader, Collection<B> collection) - Type Parameters:
B
- type of theWritableBean
to read.- Parameters:
template
- an instance of theWritableBean
to read acting as template.reader
- theStructuredReader
to read the data from.collection
- theCollection
where toadd
the unmarshalledbeans
.
-
writeArray
static <B extends WritableBean> void writeArray(Collection<B> beans, io.github.mmm.marshall.StructuredWriter writer) - Type Parameters:
B
- type of theWritableBean
to write.- Parameters:
beans
- theCollection
with thebeans
to write.writer
- theStructuredWriter
to write to.
-