- 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.PropertyBuilders
add()
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 givenWritableProperty
to this bean.WritableBean
copy(boolean isReadOnly)
protected AbstractBean
create()
Creates a new instance of thisBean
implementation.<V> io.github.mmm.property.WritableProperty<V>
createProperty(String name, Class<V> valueClass, Type valueType)
protected StandardPropertyBuilders
createPropertyBuilders()
Internal method that may be overridden to replace theStandardPropertyBuilders
implementation.Collection<? extends io.github.mmm.property.WritableProperty<?>>
getProperties()
io.github.mmm.property.WritableProperty<?>
getProperty(String name)
int
getPropertyCount()
boolean
isDynamic()
protected boolean
isLockOwnerInternal(io.github.mmm.property.AttributeReadOnly lock)
boolean
isReadOnly()
protected boolean
isThreadSafe()
AbstractBean
newInstance()
protected void
onPropertyAdded(io.github.mmm.property.WritableProperty<?> property)
String
path()
void
path(String path)
void
path(Supplier<String> pathExpression)
protected void
requireDynamic()
protected void
requireWritable()
String
toString()
void
toString(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:
path
in interfaceReadableBean
- Specified by:
path
in 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 void path(String path)
- Specified by:
path
in interfaceio.github.mmm.value.WritablePath
-
path
public void path(Supplier<String> pathExpression)
- Specified by:
path
in interfaceio.github.mmm.value.WritablePath
-
isThreadSafe
protected boolean isThreadSafe()
- Returns:
true
if theBean
shall be thread-safe (use concurrent collections, etc.),false
otherwise.
-
isDynamic
public boolean isDynamic()
- Specified by:
isDynamic
in interfaceReadableBean
- Returns:
true
if thisBean
is dynamic meaning that is not strictly typed but allows to dynamically add properties,false
otherwise.- See Also:
VirtualBean
-
requireWritable
protected void requireWritable()
-
requireDynamic
protected void requireDynamic()
-
newInstance
public AbstractBean newInstance()
- Specified by:
newInstance
in interfaceReadableBean
- Returns:
- a new instance of this
WritableBean
.
-
copy
public WritableBean copy(boolean isReadOnly)
- Specified by:
copy
in interfaceReadableBean
- Parameters:
isReadOnly
- -true
if the copy shall beread-only
.- Returns:
- a copy of this
WritableBean
that has the same values for allproperties
.
-
isReadOnly
public final boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceio.github.mmm.property.AttributeReadOnly
-
create
protected AbstractBean create()
Creates a new instance of thisBean
implementation. 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
Bean
instance. Has to be of the same type as thecurrent class
.
-
getProperties
public Collection<? extends io.github.mmm.property.WritableProperty<?>> getProperties()
- Specified by:
getProperties
in interfaceReadableBean
- Specified by:
getProperties
in interfaceWritableBean
- Returns:
- a
Collection
with allproperties
of this bean.
-
getProperty
public io.github.mmm.property.WritableProperty<?> getProperty(String name)
- Specified by:
getProperty
in interfaceReadableBean
- Specified by:
getProperty
in interfaceWritableBean
- 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:
WritableBean.addProperty(WritableProperty)
,WritableBean.getOrCreateProperty(String, Class)
-
getPropertyCount
public int getPropertyCount()
- Specified by:
getPropertyCount
in interfaceReadableBean
- Returns:
- the number of
properties
of 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:
createProperty
in interfaceWritableBean
- 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.
-
addProperty
public <P extends io.github.mmm.property.WritableProperty<?>> P addProperty(P property)
Description copied from interface:WritableBean
Adds the givenWritableProperty
to this bean.- Specified by:
addProperty
in interfaceWritableBean
- Type Parameters:
P
- type of theWritableProperty
to add.- Parameters:
property
- theWritableProperty
to 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 theWritableProperty
to add.- Parameters:
property
- theWritableProperty
to add.- Returns:
- the given
property
.
-
isLockOwnerInternal
protected boolean isLockOwnerInternal(io.github.mmm.property.AttributeReadOnly lock)
- Parameters:
lock
- thelock
to check.- Returns:
true
if this bean is the lock owner,false
otherwise.
-
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 theStandardPropertyBuilders
implementation.- Returns:
- the
StandardPropertyBuilders
instance.
-
onPropertyAdded
protected void onPropertyAdded(io.github.mmm.property.WritableProperty<?> property)
- Parameters:
property
- theWritableProperty
that has been added.
-
toString
public void toString(StringBuilder sb)
- Parameters:
sb
- theStringBuilder
where to append the details (the properties) of thisBean
fortoString()
-Representation.
-
-