- java.lang.Object
-
- io.github.mmm.bean.AbstractBean
-
- io.github.mmm.bean.AbstractVirtualBean
-
- All Implemented Interfaces:
ReadableBean
,VirtualBean
,WritableBean
,MarshallableObject
,Marshaller<Object>
,Marshalling<Object>
,MarshallingObject
,UnmarshallableObject
,Unmarshaller<Object>
,Validatable
- Direct Known Subclasses:
AdvancedBean
public abstract class AbstractVirtualBean extends AbstractBean implements VirtualBean
Implementation ofVirtualBean
as regular java class. Extend your beans from this class if you need virtual and dynamic typing.
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.bean.ReadableBean
PROPERTY_TYPE
-
-
Constructor Summary
Constructors Constructor Description AbstractVirtualBean()
The constructor.AbstractVirtualBean(BeanClass type)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AbstractBean
create()
Creates a new instance of thisBean
implementation.Iterable<? extends WritableProperty<?>>
getProperties()
WritableProperty<?>
getProperty(String name)
int
getPropertyCount()
BeanClass
getType()
boolean
isDynamic()
boolean
isPrototype()
protected boolean
isThreadSafe()
protected void
onPropertyAdded(WritableProperty<?> property)
protected void
updateProperties()
-
Methods inherited from class io.github.mmm.bean.AbstractBean
add, add, addProperty, copy, createProperty, createPropertyBuilders, isReadOnly, newInstance, requireDynamic, requireWritable, toString, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.marshall.MarshallableObject
writeObject
-
Methods inherited from interface io.github.mmm.bean.ReadableBean
copy, copy, get, getPropertyNameForAlias, isEqualTo, isPolymorphic, isReadOnly, newInstance, validate, write
-
Methods inherited from interface io.github.mmm.marshall.UnmarshallableObject
readObject
-
Methods inherited from interface io.github.mmm.bean.VirtualBean
isInstanceOf
-
Methods inherited from interface io.github.mmm.bean.WritableBean
addProperty, createProperty, createProperty, getOrCreateProperty, getOrCreateProperty, getRequiredProperty, read, set, set, set
-
-
-
-
Method Detail
-
isDynamic
public boolean isDynamic()
- Specified by:
isDynamic
in interfaceReadableBean
- Overrides:
isDynamic
in classAbstractBean
- Returns:
true
if thisBean
is dynamic meaning that is not strictly typed but allows to dynamically add properties,false
otherwise.- See Also:
VirtualBean
-
isThreadSafe
protected boolean isThreadSafe()
- Overrides:
isThreadSafe
in classAbstractBean
- Returns:
true
if theBean
shall be thread-safe (use concurrent collections, etc.),false
otherwise.
-
isPrototype
public final boolean isPrototype()
- Specified by:
isPrototype
in interfaceReadableBean
- Returns:
true
if thisBean
is aBeanClass
,false
otherwise (it is a regular instance).- See Also:
BeanClass.getPrototype()
-
getType
public BeanClass getType()
- Specified by:
getType
in interfaceReadableBean
- Specified by:
getType
in interfaceVirtualBean
- Returns:
- the
BeanType
reflecting thisBean
. - See Also:
VirtualBean.getType()
,BeanClass
-
create
protected AbstractBean create()
Description copied from class:AbstractBean
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.- Overrides:
create
in classAbstractBean
- Returns:
- the new
Bean
instance. Has to be of the same type as thecurrent class
.
-
getProperty
public WritableProperty<?> getProperty(String name)
- Specified by:
getProperty
in interfaceReadableBean
- Specified by:
getProperty
in interfaceWritableBean
- Overrides:
getProperty
in classAbstractBean
- 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
- Overrides:
getPropertyCount
in classAbstractBean
- Returns:
- the number of
properties
of thisReadableBean
.
-
getProperties
public Iterable<? extends WritableProperty<?>> getProperties()
- Specified by:
getProperties
in interfaceReadableBean
- Specified by:
getProperties
in interfaceWritableBean
- Overrides:
getProperties
in classAbstractBean
- Returns:
- an
Iterable
of all properties of this bean.
-
onPropertyAdded
protected void onPropertyAdded(WritableProperty<?> property)
- Overrides:
onPropertyAdded
in classAbstractBean
- Parameters:
property
- theWritableProperty
that has been added.
-
updateProperties
protected void updateProperties()
-
-