- 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 givenWritablePropertyto this bean.default Object<V> WritableProperty<V> createProperty(String name, Class<V> valueClass) default io.github.mmm.marshall.id.StructuredIdMappingstatic <B extends WritableBean>
Bfrom(WritableProperty<?> property) default <V> WritableProperty<V> getOrCreateProperty(String name, Class<V> valueClass) Collection<? extends WritableProperty<?>> getProperty(String name) static <B extends WritableBean>
BgetReadOnly(B bean) default WritableProperty<?> getRequiredProperty(String name) getType()voidpathSegment(String pathSegment) Used to set an alias as described inpathSegment().default WritableBeanread(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 voiddefault <V> void/** Sets the value of theexisting or newly created propertywith the givennameto the givenvalue.default voidsetDynamic(String name, Object value) default voidwrite(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
isReadOnlyMethods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObjectMethods inherited from interface io.github.mmm.bean.ReadableBean
copy, doEquals, doToString, get, getAliases, getJavaClass, getPropertyCount, isDynamic, isEqual, isPolymorphic, isPrototype, mapPropertyIds, newInstance, toString, validateMethods inherited from interface io.github.mmm.value.ReadablePath
parentPath, path, path, pathMethods inherited from interface io.github.mmm.marshall.UnmarshallableObject
readObjectMethods inherited from interface io.github.mmm.validation.Validatable
validateOrThrowMethods inherited from interface io.github.mmm.value.WritablePath
parentPath
-
Method Details
-
getProperty
- 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:
-
getProperties
Collection<? extends WritableProperty<?>> getProperties()- Specified by:
getPropertiesin interfaceReadableBean- Returns:
- a
Collectionwith allpropertiesof this bean.
-
getRequiredProperty
- Specified by:
getRequiredPropertyin interfaceReadableBean- Parameters:
name- thenameof the requested property.- Returns:
- the requested
property.
-
set
- Parameters:
name- thenameof the property.value- newvalueof the specified property.
-
setDynamic
Sets the value of thepropertywith the givennameto the givenvalue. If no suchpropertyexists, it will becreateddynamicallyif the given value is notnull.- Parameters:
name- thenameof the property.value- newvalueof the specified property.
-
set
/** Sets the value of theexisting or newly created propertywith the givennameto the givenvalue.- Type Parameters:
V- the generic type of thevalue class.- Parameters:
name- theproperty name.value- newvalueof the specified property.valueClass- thevalue class.- See Also:
-
addProperty
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
- 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.
-
getOrCreateProperty
- 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.
-
getType
BeanType getType()- Specified by:
getTypein interfaceReadableBean- Returns:
- the
BeanTypereflecting thisBean. - See Also:
-
getReadOnly
WritableBean getReadOnly() -
read
- Specified by:
readin interfaceio.github.mmm.marshall.UnmarshallableObject
-
write
default void write(io.github.mmm.marshall.StructuredWriter writer) - Specified by:
writein interfaceio.github.mmm.marshall.MarshallableObject
-
defineIdMapping
default io.github.mmm.marshall.id.StructuredIdMapping defineIdMapping()- Specified by:
defineIdMappingin interfaceio.github.mmm.marshall.id.StructuredIdMappingObject
-
asTypeKey
- Specified by:
asTypeKeyin interfaceio.github.mmm.marshall.id.StructuredIdMappingObject
-
pathSegment
String pathSegment()- Specified by:
pathSegmentin 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:
pathSegmentin interfaceio.github.mmm.value.WritablePath
-
getReadOnly
- Type Parameters:
B- type of theWritableBean.- Parameters:
bean- theWritableBeanto get aread-onlyviewof.- Returns:
- the
read-onlyviewof the givenWritableBean.
-
from
- Type Parameters:
B- type of theWritableBeanowning theproperty.- Parameters:
property- theWritablePropertyfor which the owningWritableBeanis requested.- Returns:
- the
WritableBeanowning the givenproperty. Will benullif theWritablePropertyis 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 theWritableBeanto read.- Parameters:
template- an instance of theWritableBeanto read acting as template.reader- theStructuredReaderto read the data from.- Returns:
- the
Listwith 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 theWritableBeanto read.- Parameters:
template- an instance of theWritableBeanto read acting as template.reader- theStructuredReaderto read the data from.collection- theCollectionwhere toaddthe unmarshalledbeans.
-
writeArray
static <B extends WritableBean> void writeArray(Collection<B> beans, io.github.mmm.marshall.StructuredWriter writer) - Type Parameters:
B- type of theWritableBeanto write.- Parameters:
beans- theCollectionwith thebeansto write.writer- theStructuredWriterto write to.
-