Class DefaultParameterSchema

  • All Implemented Interfaces:
    ParameterSchema

    public class DefaultParameterSchema
    extends Object
    implements ParameterSchema
    Default implementation of ParameterSchema.
    Author:
    Nick Collier
    • Constructor Detail

      • DefaultParameterSchema

        public DefaultParameterSchema​(ParameterSchema schema)
      • DefaultParameterSchema

        public DefaultParameterSchema​(String name,
                                      Class type,
                                      Object defValue)
      • DefaultParameterSchema

        public DefaultParameterSchema​(String name,
                                      Class type,
                                      Object defValue,
                                      List possibleValues)
    • Method Detail

      • setConvertor

        public void setConvertor​(StringConverter converter)
        Sets the converter for this schema.
        Parameters:
        converter - the converter
      • getName

        public String getName()
        Gets the name of the parameter that this is the schema for.
        Specified by:
        getName in interface ParameterSchema
        Returns:
        the name of the parameter that this is the schema for.
      • getType

        public Class getType()
        Gets the type of the parameter.
        Specified by:
        getType in interface ParameterSchema
        Returns:
        the type of the parameter.
      • getDefaultValue

        public Object getDefaultValue()
        Gets the default value of the parameter.
        Specified by:
        getDefaultValue in interface ParameterSchema
        Returns:
        the default value of the parameter.
      • setDefaultValue

        public void setDefaultValue​(Object obj)
        Sets the default value of this parameter.
        Specified by:
        setDefaultValue in interface ParameterSchema
        Parameters:
        obj - the new default value
      • setConstrainingList

        public void setConstrainingList​(List list)
        Sets the constraining list.
        Parameters:
        list - the constraining list
      • setConstrainingRange

        public void setConstrainingRange​(SteppedRange range)
        Sets the constraining range.
        Parameters:
        range - the constraining range.
      • getConstrainingRange

        public SteppedRange getConstrainingRange()
        Gets the numeric range of values that constrain this parameter. This will return null if the parameter is unconstrained by a numeric range.
        Specified by:
        getConstrainingRange in interface ParameterSchema
        Returns:
        the numeric range of values that constrain this parameter or null if the parameter is unconstrained by a range.
      • getConstrainingList

        public List getConstrainingList()
        Gets the list of values that constrain this parameter. This will return null if the parameter is unconstrained by a list.
        Specified by:
        getConstrainingList in interface ParameterSchema
        Returns:
        the list of values that constrain this parameter or null if the parameter is unconstrained by a list of possible values.
      • getConstraintString

        public String getConstraintString()
        Gets the string representation of the values or range that constrain this parameter This will return an empty string if the parameter is not constrained (by a list or range)
        Specified by:
        getConstraintString in interface ParameterSchema
        Returns:
        the string representation of the parameter constraints, if unconstrained an empty string
      • validate

        public boolean validate​(Object obj)
        Validates the specified object against the type and optional constraint info for the parameter name.
        Specified by:
        validate in interface ParameterSchema
        Parameters:
        obj - the object to validate
        Returns:
        true if the object is of a type valid for the parameter, otherwise false.
      • toString

        public String toString​(Object obj)
        Description copied from interface: ParameterSchema
        Converts the object into a String representation.
        Specified by:
        toString in interface ParameterSchema
        Parameters:
        obj - the object to convert
        Returns:
        the String representation.
      • fromString

        public Object fromString​(String str)
        Description copied from interface: ParameterSchema
        Creates an Object from the String representation.
        Specified by:
        fromString in interface ParameterSchema
        Parameters:
        str - the String representation
        Returns:
        the created Object