Class FieldProviderFactory

  • All Implemented Interfaces:
    Serializable, FieldProvider

    public class FieldProviderFactory
    extends Object
    implements FieldProvider
    FieldProviderFactory is an utility class to obtain a FieldProvider object from any Object with getter methods.

    Its is used invoking the static getFieldProvider or getFieldProviderArray methods with an object or array of objects as parameter. These objects must have getter methods, the FieldProvider.getField method will call the getter with the same name. Example: MyClass obj = new MyClass(); FieldProvider fp = FieldProviderFactory.getFieldProvider(obj); String name = fp.getField("name"); This example will call to obj.getName() method.

    See Also:
    Serialized Form
    • Constructor Detail

      • FieldProviderFactory

        public FieldProviderFactory​(Object obj)
        Initializes a new FieldProviderFactory for the object
        obj -
    • Method Detail

      • getField

        public String getField​(String fieldName)
        This is the implementation for the FieldProvider.getField(String s) method which will be invoked in the object.

        Note that for a fieldName it must exist in the object a getter called "getFieldName" "F" is upper case though in the passed parameter can be lower case.

        Specified by:
        getField in interface FieldProvider
      • getFieldProvider

        public static FieldProvider getFieldProvider​(Object obj)
        Returns a FieldProvider for the getter methods of object
        obj -
        the FieldProvider for the passed obj.
      • getFieldProviderArray

        public static FieldProvider[] getFieldProviderArray​(Object[] obj)
        Returns an array of FieldProvider objects for the getter methods of the objects
        obj -
        an array of FieldProviders for each of the objects in the passed array
      • setField

        public static void setField​(FieldProvider fp,
                                    String field,
                                    String value)
        Creates a setter for a field provider
        fp -
        field -
        value -