Class PropBinder


  • public class PropBinder
    extends java.lang.Object
    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 Detail

      • PropBinder

        public PropBinder()
    • Method Detail

      • populatePOJO

        public static BinderActions populatePOJO​(IPropBinder pojo,
                                                 PropCnr container)
                                          throws java.lang.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 the pojo.
        Returns:
        A BinderActions object indicating the actions taken.
        Throws:
        java.lang.NullPointerException - if one or both of the pojo or property parameters are null.
      • populatePOJO

        public static BinderActions populatePOJO​(IPropBinder pojo,
                                                 PropCnr container,
                                                 boolean doSkipProperty,
                                                 int depth)
                                          throws java.lang.NullPointerException,
                                                 java.lang.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 the pojo.
        doSkipProperty - flag indicating a property who doesn't have a pojo Field with 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 BinderActions object indicating the actions taken.
        Throws:
        java.lang.NullPointerException - if one or both of the pojo or property parameters are null.
        java.lang.IllegalArgumentException - if the depth is not valid, i.e. not -1, 0 or higher.
      • populateProp

        public static BinderActions populateProp​(IPropBinder pojo,
                                                 PropCnr container)
        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 BinderActions object indicating the actions taken. null is returned if the field is not found.
        Throws:
        java.lang.NullPointerException - if one or both of the pojo or property parameters are null.
      • 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 BinderActions object indicating the actions taken. null is returned if the field is not found.
        Throws:
        java.lang.NullPointerException - if one or both of the pojo or property parameters are null.
        java.lang.IllegalArgumentException - if the depth is not valid, i.e. not -1, 0 or higher.