|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.beans.impl.BasicBean
org.joda.beans.impl.flexi.FlexiBean
public final class FlexiBean
Implementation of a fully dynamic Bean.
Properties are dynamic, and can be added and removed at will from the map. The internal storage is created lazily to allow a flexi-bean to be used as a lightweight extension to another bean.
| Constructor Summary | |
|---|---|
FlexiBean()
Constructor. |
|
FlexiBean(FlexiBean copyFrom)
Constructor that copies all the data entries from the specified bean. |
|
| Method Summary | ||
|---|---|---|
FlexiBean |
append(String propertyName,
Object newValue)
Adds or updates a property returning this for chaining. |
|
void |
clear()
Removes all properties. |
|
boolean |
contains(String propertyName)
Checks if the bean contains a specific property. |
|
boolean |
equals(Object obj)
Compares this bean to another based on the property names and content. |
|
Object |
get(String propertyName)
Gets the value of the property. |
|
|
get(String propertyName,
Class<T> type)
Gets the value of the property cast to a specific type. |
|
boolean |
getBoolean(String propertyName)
Gets the value of the property as a boolean. |
|
double |
getDouble(String propertyName)
Gets the value of the property as a double. |
|
double |
getDouble(String propertyName,
double defaultValue)
Gets the value of the property as a double using a default value. |
|
int |
getInt(String propertyName)
Gets the value of the property as a int. |
|
int |
getInt(String propertyName,
int defaultValue)
Gets the value of the property as a int using a default value. |
|
long |
getLong(String propertyName)
Gets the value of the property as a long. |
|
long |
getLong(String propertyName,
long defaultValue)
Gets the value of the property as a long using a default value. |
|
String |
getString(String propertyName)
Gets the value of the property as a String. |
|
int |
hashCode()
Returns a suitable hash code. |
|
MetaBean |
metaBean()
Gets the meta-bean representing the parts of the bean that are common across all instances, such as the set of meta-properties. |
|
Property<Object> |
property(String name)
Gets a property by name. |
|
void |
propertyDefine(String propertyName,
Class<?> propertyType)
Adds a property to those allowed to be stored in the bean. |
|
boolean |
propertyExists(String propertyName)
Checks if the property exists. |
|
Object |
propertyGet(String propertyName)
Gets the value of the property. |
|
Set<String> |
propertyNames()
Gets the set of property names. |
|
void |
propertyRemove(String propertyName)
Removes a property by name. |
|
void |
propertySet(String propertyName,
Object newValue)
Sets the value of the property. |
|
Object |
put(String propertyName,
Object newValue)
Puts the property into this bean. |
|
void |
putAll(FlexiBean other)
Puts the properties in the specified bean into this bean. |
|
void |
putAll(Map<String,Object> map)
Puts the properties in the specified map into this bean. |
|
void |
remove(String propertyName)
Removes a property. |
|
void |
set(String propertyName,
Object newValue)
Adds or updates a property. |
|
int |
size()
Gets the number of properties. |
|
Map<String,Object> |
toMap()
Returns a map representing the contents of the bean. |
|
String |
toString()
Returns a string that summarises the bean. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FlexiBean()
public FlexiBean(FlexiBean copyFrom)
copyFrom - the bean to copy from, not null| Method Detail |
|---|
public int size()
public boolean contains(String propertyName)
propertyName - the property name, null returns false
public Object get(String propertyName)
propertyName - the property name, not empty
public <T> T get(String propertyName,
Class<T> type)
T - the value typepropertyName - the property name, not emptytype - the type to cast to, not null
public String getString(String propertyName)
String.
This will use Object.toString().
propertyName - the property name, not empty
public boolean getBoolean(String propertyName)
boolean.
propertyName - the property name, not empty
ClassCastException - if the value is not compatiblepublic int getInt(String propertyName)
int.
propertyName - the property name, not empty
ClassCastException - if the value is not compatible
public int getInt(String propertyName,
int defaultValue)
int using a default value.
propertyName - the property name, not emptydefaultValue - the default value for null
ClassCastException - if the value is not compatiblepublic long getLong(String propertyName)
long.
propertyName - the property name, not empty
ClassCastException - if the value is not compatible
public long getLong(String propertyName,
long defaultValue)
long using a default value.
propertyName - the property name, not emptydefaultValue - the default value for null
ClassCastException - if the value is not compatiblepublic double getDouble(String propertyName)
double.
propertyName - the property name, not empty
ClassCastException - if the value is not compatible
public double getDouble(String propertyName,
double defaultValue)
double using a default value.
propertyName - the property name, not emptydefaultValue - the default value for null
ClassCastException - if the value is not compatible
public FlexiBean append(String propertyName,
Object newValue)
this for chaining.
propertyName - the property name, not emptynewValue - the new value, may be null
this for chaining, not null
public void set(String propertyName,
Object newValue)
propertyName - the property name, not emptynewValue - the new value, may be null
public Object put(String propertyName,
Object newValue)
propertyName - the property name, not emptynewValue - the new value, may be null
public void putAll(Map<String,Object> map)
map - the map of properties to add, not nullpublic void putAll(FlexiBean other)
other - the map of properties to add, not nullpublic void remove(String propertyName)
propertyName - the property name, not emptypublic void clear()
public boolean propertyExists(String propertyName)
propertyName - the property name, not empty
public Object propertyGet(String propertyName)
propertyName - the property name, not empty
public void propertySet(String propertyName,
Object newValue)
propertyName - the property name, not emptynewValue - the new value of the property, may be nullpublic MetaBean metaBean()
Bean
metaBean in interface Beanpublic Property<Object> property(String name)
Bean
property in interface Beanproperty in class BasicBeanname - the property name to retrieve, null throws NoSuchElementException
public Set<String> propertyNames()
Bean
propertyNames in interface BeanpropertyNames in class BasicBean
public void propertyDefine(String propertyName,
Class<?> propertyType)
DynamicBeanSome implementations will automatically add properties, in which case this method will have no effect.
propertyDefine in interface DynamicBeanpropertyName - the property name to check, not empty, not nullpropertyType - the property type, not nullpublic void propertyRemove(String propertyName)
DynamicBean
propertyRemove in interface DynamicBeanpropertyName - the property name to remove, null ignoredpublic Map<String,Object> toMap()
public boolean equals(Object obj)
equals in class BasicBeanobj - the object to compare to, null returns false
public int hashCode()
hashCode in class BasicBeanpublic String toString()
The string contains the class name and properties.
toString in class BasicBean
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||