- 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 ofVirtualBeanas 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 AbstractBeancreate()Creates a new instance of thisBeanimplementation.Iterable<? extends WritableProperty<?>>getProperties()WritableProperty<?>getProperty(String name)intgetPropertyCount()BeanClassgetType()booleanisDynamic()booleanisPrototype()protected booleanisThreadSafe()protected voidonPropertyAdded(WritableProperty<?> property)protected voidupdateProperties()-
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:
isDynamicin interfaceReadableBean- Overrides:
isDynamicin classAbstractBean- Returns:
trueif thisBeanis dynamic meaning that is not strictly typed but allows to dynamically add properties,falseotherwise.- See Also:
VirtualBean
-
isThreadSafe
protected boolean isThreadSafe()
- Overrides:
isThreadSafein classAbstractBean- Returns:
trueif theBeanshall be thread-safe (use concurrent collections, etc.),falseotherwise.
-
isPrototype
public final boolean isPrototype()
- Specified by:
isPrototypein interfaceReadableBean- Returns:
trueif thisBeanis aBeanClass,falseotherwise (it is a regular instance).- See Also:
BeanClass.getPrototype()
-
getType
public BeanClass getType()
- Specified by:
getTypein interfaceReadableBean- Specified by:
getTypein interfaceVirtualBean- Returns:
- the
BeanTypereflecting thisBean. - See Also:
VirtualBean.getType(),BeanClass
-
create
protected AbstractBean create()
Description copied from class:AbstractBeanCreates 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.- Overrides:
createin classAbstractBean- Returns:
- the new
Beaninstance. Has to be of the same type as thecurrent class.
-
getProperty
public WritableProperty<?> getProperty(String name)
- Specified by:
getPropertyin interfaceReadableBean- Specified by:
getPropertyin interfaceWritableBean- Overrides:
getPropertyin classAbstractBean- 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- Overrides:
getPropertyCountin classAbstractBean- Returns:
- the number of
propertiesof thisReadableBean.
-
getProperties
public Iterable<? extends WritableProperty<?>> getProperties()
- Specified by:
getPropertiesin interfaceReadableBean- Specified by:
getPropertiesin interfaceWritableBean- Overrides:
getPropertiesin classAbstractBean- Returns:
- an
Iterableof all properties of this bean.
-
onPropertyAdded
protected void onPropertyAdded(WritableProperty<?> property)
- Overrides:
onPropertyAddedin classAbstractBean- Parameters:
property- theWritablePropertythat has been added.
-
updateProperties
protected void updateProperties()
-
-