java.lang.Object
io.github.mmm.bean.AbstractBean
- All Implemented Interfaces:
ReadableBean,WritableBean,io.github.mmm.marshall.MarshallableObject,io.github.mmm.marshall.Marshaller<Object>,io.github.mmm.marshall.Marshalling<Object>,io.github.mmm.marshall.MarshallingObject,io.github.mmm.marshall.UnmarshallableObject,io.github.mmm.marshall.Unmarshaller<Object>,AttributeReadOnly,io.github.mmm.validation.Validatable,io.github.mmm.value.ReadablePath,io.github.mmm.value.WritablePath
- Direct Known Subclasses:
AbstractVirtualBean,Bean,BeanAccessor
Abstract base implementation of
WritableBean.- See Also:
-
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
PROPERTY_TYPE_ID, PROPERTY_TYPE_NAME, SUFFIX_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertyBuildersadd()protected <V,P extends WritableProperty<V>>
Padd(P property) Internal method foraddProperty(WritableProperty), without verification.<P extends WritableProperty<?>>
PaddProperty(P property) Adds the givenWritablePropertyto this bean.copy(boolean isReadOnly) protected AbstractBeancreate()Creates a new instance of thisBeanimplementation.<V> WritableProperty<V>createProperty(String name, Class<V> valueClass, Type valueType) protected StandardPropertyBuildersInternal method that may be overridden to replace theStandardPropertyBuildersimplementation.Collection<? extends WritableProperty<?>>getProperty(String name) intbooleanprotected booleanfinal booleanprotected booleanprotected static booleanisThreadSafe(AbstractBean bean) Internal method to get access toisThreadSafe().protected voidonPropertyAdded(WritableProperty<?> property) io.github.mmm.value.ReadablePathvoidparentPath(io.github.mmm.value.ReadablePath parent) path(boolean fixed) voidpathSegment(String path) Used to set an alias as described inWritableBean.pathSegment().protected voidregisterAlias(String propertyName, String alias) protected voidregisterAliases(String propertyName, String... propertyAliases) protected voidprotected voidtoString()voidwrite(io.github.mmm.marshall.StructuredWriter writer) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObjectMethods inherited from interface io.github.mmm.bean.ReadableBean
doEquals, doToString, get, getType, isEqualTo, isPolymorphic, isPrototype, mapPropertyIds, toString, validateMethods inherited from interface io.github.mmm.value.ReadablePath
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.bean.WritableBean
createProperty, getOrCreateProperty, getOrCreateProperty, getRequiredProperty, read, set, set, set, setDynamic
-
Constructor Details
-
AbstractBean
public AbstractBean()The constructor.
-
-
Method Details
-
pathSegment
- Specified by:
pathSegmentin interfaceio.github.mmm.value.ReadablePath- Specified by:
pathSegmentin interfaceWritableBean- 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
Description copied from interface:WritableBeanUsed to set an alias as described inWritableBean.pathSegment(). 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 interfaceWritableBean- Specified by:
pathSegmentin interfaceio.github.mmm.value.WritablePath
-
parentPath
public io.github.mmm.value.ReadablePath parentPath()- Specified by:
parentPathin interfaceio.github.mmm.value.ReadablePath
-
parentPath
public void parentPath(io.github.mmm.value.ReadablePath parent) - Specified by:
parentPathin interfaceio.github.mmm.value.WritablePath
-
path
- Specified by:
pathin interfaceio.github.mmm.value.ReadablePath
-
isThreadSafe
protected boolean isThreadSafe()- Returns:
trueif theBeanshall be thread-safe (use concurrent collections, etc.),falseotherwise.
-
isDynamic
public boolean isDynamic()- Specified by:
isDynamicin interfaceReadableBean- Returns:
trueif thisBeanis dynamic meaning that is not strictly typed but allows to dynamically add properties,falseotherwise.- See Also:
-
requireWritable
protected void requireWritable() -
requireDynamic
protected void requireDynamic() -
newInstance
- Specified by:
newInstancein interfaceReadableBean- Returns:
- a new instance of this
WritableBean.
-
copy
- Specified by:
copyin interfaceReadableBean- Parameters:
isReadOnly- -trueif the copy shall beread-only.- Returns:
- a copy of this
WritableBeanthat has the same values for allproperties.
-
isReadOnly
public final boolean isReadOnly()- Specified by:
isReadOnlyin interfaceAttributeReadOnly
-
create
Creates a new instance of thisBeanimplementation. The default implementation uses reflection. To improve performance please override this method. Please note, that if you do so, you also need to override this method again for all sub-classes of the hierarchy.- Returns:
- the new
Beaninstance. Has to be of the same type as thecurrent class.
-
getProperties
- Specified by:
getPropertiesin interfaceReadableBean- Specified by:
getPropertiesin interfaceWritableBean- Returns:
- a
Collectionwith allpropertiesof this bean.
-
getProperty
- Specified by:
getPropertyin interfaceReadableBean- Specified by:
getPropertyin interfaceWritableBean- Parameters:
name- thenameof the requested property or a potentialaliasof the property.- Returns:
- the requested
WritablePropertyornullif no such property exists. - See Also:
-
getPropertyCount
public int getPropertyCount()- Specified by:
getPropertyCountin interfaceReadableBean- Returns:
- the number of
propertiesof thisReadableBean.
-
createProperty
Description copied from interface:WritableBean- Specified by:
createPropertyin interfaceWritableBean- 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.
-
addProperty
Description copied from interface:WritableBeanAdds the givenWritablePropertyto this bean.- Specified by:
addPropertyin interfaceWritableBean- Type Parameters:
P- type of theWritablePropertyto add.- Parameters:
property- theWritablePropertyto add.- Returns:
- the given
property.
-
add
Internal method foraddProperty(WritableProperty), without verification. Will be called from constructor of bean class implementations to register properties.- Type Parameters:
V- type of theproperty value.P- type of theWritablePropertyto add.- Parameters:
property- theWritablePropertyto add.- Returns:
- the given
property.
-
isLockOwnerInternal
- Parameters:
lock- thelockto check.- Returns:
trueif this bean is the lock owner,falseotherwise.
-
add
- Returns:
- the builder factory to build properties to be added to this bean.
-
createPropertyBuilders
Internal method that may be overridden to replace theStandardPropertyBuildersimplementation.- Returns:
- the
StandardPropertyBuildersinstance.
-
onPropertyAdded
- Parameters:
property- theWritablePropertythat has been added.
-
write
public void write(io.github.mmm.marshall.StructuredWriter writer) - Specified by:
writein interfaceio.github.mmm.marshall.MarshallableObject
-
registerAlias
- Parameters:
propertyName- theproperty name.alias- thealiasto add.
-
registerAliases
- Parameters:
propertyName- theproperty name.propertyAliases- thealiasesto add.
-
getAliases
- Specified by:
getAliasesin interfaceReadableBean- Returns:
- the
BeanAliasMapwith potential aliases forpropertynames.
-
toString
-
isThreadSafe
Internal method to get access toisThreadSafe().- Parameters:
bean- theAbstractBean.- Returns:
- the value of
isThreadSafe().
-