- 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>,io.github.mmm.property.AttributeReadOnly,io.github.mmm.validation.Validatable,io.github.mmm.value.ReadablePath,io.github.mmm.value.WritablePath
- Direct Known Subclasses:
AbstractVirtualBean,Bean
public abstract class AbstractBean extends Object implements WritableBean
Abstract base implementation ofWritableBean.- See Also:
Bean
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.bean.ReadableBean
PROPERTY_TYPE, SUFFIX_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractBean()The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.github.mmm.property.builder.PropertyBuildersadd()protected <V,P extends io.github.mmm.property.WritableProperty<V>>
Padd(P property)Internal method foraddProperty(WritableProperty), without verification.<P extends io.github.mmm.property.WritableProperty<?>>
PaddProperty(P property)Adds the givenWritablePropertyto this bean.WritableBeancopy(boolean isReadOnly)protected AbstractBeancreate()Creates a new instance of thisBeanimplementation.<V> io.github.mmm.property.WritableProperty<V>createProperty(String name, Class<V> valueClass, Type valueType)protected StandardPropertyBuilderscreatePropertyBuilders()Internal method that may be overridden to replace theStandardPropertyBuildersimplementation.Collection<? extends io.github.mmm.property.WritableProperty<?>>getProperties()io.github.mmm.property.WritableProperty<?>getProperty(String name)intgetPropertyCount()booleanisDynamic()protected booleanisLockOwnerInternal(io.github.mmm.property.AttributeReadOnly lock)booleanisReadOnly()protected booleanisThreadSafe()AbstractBeannewInstance()protected voidonPropertyAdded(io.github.mmm.property.WritableProperty<?> property)Stringpath()Stringpath(String newPath)protected voidrequireDynamic()protected voidrequireWritable()StringtoString()voidtoString(StringBuilder sb)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.bean.ReadableBean
get, getPropertyNameForAlias, getType, isEqualTo, isPolymorphic, isPrototype, validate, write
-
Methods inherited from interface io.github.mmm.bean.WritableBean
createProperty, getOrCreateProperty, getOrCreateProperty, getRequiredProperty, read, set, set, set
-
-
-
-
Method Detail
-
path
public String path()
- Specified by:
pathin interfaceReadableBean- Specified by:
pathin interfaceio.github.mmm.value.ReadablePath- Returns:
- the path of this bean. It will be appended as prefix to the
ReadableBean.path()of allproperties. This is useful for criteria API to build queries. So e.g. set to "e." if this bean should have the query alias "e".
-
path
public String path(String newPath)
- Specified by:
pathin interfaceio.github.mmm.value.WritablePath
-
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:
VirtualBean
-
requireWritable
protected void requireWritable()
-
requireDynamic
protected void requireDynamic()
-
newInstance
public AbstractBean newInstance()
- Specified by:
newInstancein interfaceReadableBean- Returns:
- a new instance of this
WritableBean.
-
copy
public WritableBean copy(boolean isReadOnly)
- 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 interfaceio.github.mmm.property.AttributeReadOnly
-
create
protected AbstractBean 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
public Collection<? extends io.github.mmm.property.WritableProperty<?>> getProperties()
- Specified by:
getPropertiesin interfaceReadableBean- Specified by:
getPropertiesin interfaceWritableBean- Returns:
- an
Iterableof all properties of this bean.
-
getProperty
public io.github.mmm.property.WritableProperty<?> getProperty(String name)
- 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:
WritableBean.addProperty(WritableProperty),WritableBean.getOrCreateProperty(String, Class)
-
getPropertyCount
public int getPropertyCount()
- Specified by:
getPropertyCountin interfaceReadableBean- Returns:
- the number of
propertiesof thisReadableBean.
-
createProperty
public <V> io.github.mmm.property.WritableProperty<V> createProperty(String name, Class<V> valueClass, Type valueType)
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
public <P extends io.github.mmm.property.WritableProperty<?>> P addProperty(P property)
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
protected <V,P extends io.github.mmm.property.WritableProperty<V>> P add(P property)
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
protected boolean isLockOwnerInternal(io.github.mmm.property.AttributeReadOnly lock)
- Parameters:
lock- thelockto check.- Returns:
trueif this bean is the lock owner,falseotherwise.
-
add
protected io.github.mmm.property.builder.PropertyBuilders add()
- Returns:
- the builder factory to build properties to be added to this bean.
-
createPropertyBuilders
protected StandardPropertyBuilders createPropertyBuilders()
Internal method that may be overridden to replace theStandardPropertyBuildersimplementation.- Returns:
- the
StandardPropertyBuildersinstance.
-
onPropertyAdded
protected void onPropertyAdded(io.github.mmm.property.WritableProperty<?> property)
- Parameters:
property- theWritablePropertythat has been added.
-
toString
public void toString(StringBuilder sb)
- Parameters:
sb- theStringBuilderwhere to append the details (the properties) of thisBeanfortoString()-Representation.
-
-