Package com.iizix.prop
Class PropBinder
java.lang.Object
com.iizix.prop.PropBinder
The PropertyBinder class is used to bind a POJO (Plain Old Java Object) to properties, and vice versa.
Name conversion
The system property names with atom names starting with the "$" character are transposed to POJO variables starting with the "$" dollar sign, and vice versa.
Property to POJO data bindings
BoolProp Boolean or String (as "true" or "false")
BoolProp Number (as 0 or !=0 [like in C/C++]), i.e. BigDecimal/BigInteger/Double/Float/Long/Integer/Short/Byte], String (as "true" or "false")
ColorPrope GColor, (AWT) Color, String (as e.g. "rgba(r,g,b,a)")
...etc... ...The list if VERY long... For now, look up the individual static Property class array called "valueTypes".
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic BinderActionspopulatePOJO(IPropBinder pojo, PropCnr container) Populates an instance of a POJO with data from properties in a property container, skipping sub-containers, but without skipping non-found properties.static BinderActionspopulatePOJO(IPropBinder pojo, PropCnr container, boolean doSkipProperty, int depth) Populates an instance of a POJO with data from properties in a container.static BinderActionspopulateProp(BinderActions ba, IPropBinder pojo, PropCnr container, int depth, boolean skipUnknownFields, boolean createNewProperties) Populates a property from a POJO object.static BinderActionspopulateProp(IPropBinder pojo, PropCnr container) Populates a property from a POJO object.
Constructor Details
PropBinder
public PropBinder()
Method Details
populatePOJO
public static BinderActions populatePOJO(IPropBinder pojo, PropCnr container) throws NullPointerException Populates an instance of a POJO with data from properties in a property container, skipping sub-containers, but without skipping non-found properties.- Parameters:
pojo- the Plain Old Java Object instance that will be populated by the properties.container- the base property that is used to populate thepojo.- Returns:
- A
BinderActionsobject indicating the actions taken. - Throws:
NullPointerException- if one or both of thepojoorpropertyparameters arenull.
populatePOJO
public static BinderActions populatePOJO(IPropBinder pojo, PropCnr container, boolean doSkipProperty, int depth) throws NullPointerException, IllegalArgumentException Populates an instance of a POJO with data from properties in a container.- Parameters:
pojo- the Plain Old Java Object instance that will be populated by the properties.container- the container property that is used to populate thepojo.doSkipProperty- flag indicating a property who doesn't have apojo Fieldwith the same name should be skipped.depth- the depth in the container structure that should be populated. A depth of zero indicates just this container, a higher depth indicates how many sub-containers that also should be used for population. -1 indicates all available containers.- Returns:
- A
BinderActionsobject indicating the actions taken. - Throws:
NullPointerException- if one or both of thepojoorpropertyparameters arenull.IllegalArgumentException- if the depth is not valid, i.e. not -1, 0 or higher.
populateProp
Populates a property from a POJO object.- Parameters:
pojo- The Plain Old Java Object to populate with the property data.container- The property to populate from the object.- Returns:
- A
BinderActionsobject indicating the actions taken.nullis returned if the field is not found. - Throws:
NullPointerException- if one or both of thepojoorpropertyparameters arenull.
populateProp
public static BinderActions populateProp(BinderActions ba, IPropBinder pojo, PropCnr container, int depth, boolean skipUnknownFields, boolean createNewProperties) Populates a property from a POJO object.- Parameters:
pojo- The Plain Old Java Object to populate with the property data.container- The property to populate from the object.- Returns:
- A
BinderActionsobject indicating the actions taken.nullis returned if the field is not found. - Throws:
NullPointerException- if one or both of thepojoorpropertyparameters arenull.IllegalArgumentException- if the depth is not valid, i.e. not -1, 0 or higher.