Class Parameter


  • public class Parameter
    extends Object
    A parameter that needs to be set for a some operation or configuration.
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • Parameter

        public Parameter()
        Default constructor.
      • Parameter

        public Parameter​(String name,
                         Class type,
                         String label,
                         String hint,
                         boolean required,
                         Object value)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
        type - The type of the parameter.
        required - Whether the parameter is required (true) or optional (false).
        value - The value (or default value) of the parameter.
      • Parameter

        public Parameter​(String name,
                         String label,
                         String hint,
                         boolean required,
                         Object value)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
        required - Whether the parameter is required (true) or optional (false).
        value - The value (or default value) of the parameter.
      • Parameter

        public Parameter​(String name,
                         Class type,
                         String label,
                         String hint,
                         boolean required)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
        type - The type of the parameter.
        required - Whether the parameter is required (true) or optional (false).
      • Parameter

        public Parameter​(String name,
                         Class type,
                         String label,
                         String hint,
                         Object value)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
        type - The type of the parameter.
        value - The value (or default value) of the parameter.
      • Parameter

        public Parameter​(String name,
                         String label,
                         String hint,
                         Object value)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
        value - The value (or default value) of the parameter.
      • Parameter

        public Parameter​(String name,
                         Class type,
                         String label,
                         String hint)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        type - The type of the parameter.
        label - A label that might be presented to a user.
        hint - A text hint that might be displayed to a user.
      • Parameter

        public Parameter​(String name,
                         Class type,
                         String label)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        type - The type of the parameter.
        label - A label that might be presented to a user.
      • Parameter

        public Parameter​(String name,
                         Class type)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        type - The type of the parameter.
      • Parameter

        public Parameter​(String name,
                         Object value)
        Constructor from attributes.
        Parameters:
        name - The paramater's name.
        value - The value (or default value) of the parameter.
    • Method Detail

      • getName

        public String getName()
        Getter for name: The paramater's name.
        Returns:
        The paramater's name.
      • setName

        public Parameter setName​(String newName)
        Setter for name: The paramater's name.
        Parameters:
        newName - The paramater's name.
      • getLabel

        public String getLabel()
        Getter for label: A label that might be presented to a user.
        Returns:
        A label that might be presented to a user.
      • setLabel

        public Parameter setLabel​(String newLabel)
        Setter for label: A label that might be presented to a user.
        Parameters:
        newLabel - A label that might be presented to a user.
      • getHint

        public String getHint()
        Getter for hint: A text hint that might be displayed to a user.
        Returns:
        A text hint that might be displayed to a user.
      • setHint

        public Parameter setHint​(String newHint)
        Setter for hint: A text hint that might be displayed to a user.
        Parameters:
        newHint - A text hint that might be displayed to a user.
      • getType

        public Class getType()
        Getter for type: The type of the parameter.
        Returns:
        The type of the parameter.
      • setType

        public Parameter setType​(Class newType)
        Setter for type: The type of the parameter.
        Parameters:
        newType - The type of the parameter.
      • getValue

        public Object getValue()
        Getter for value: The value (or default value) of the parameter.
        Returns:
        The value (or default value) of the parameter.
      • setValue

        public Parameter setValue​(Object newValue)
        Setter for value: The value (or default value) of the parameter.
        Parameters:
        newValue - The value (or default value) of the parameter.
      • getRequired

        public boolean getRequired()
        Getter for required: Whether the parameter is required (true) or optional (false - the default).
        Returns:
        Whether the parameter is required (true) or optional (false).
      • setRequired

        public Parameter setRequired​(boolean newRequired)
        Setter for required: Whether the parameter is required (true) or optional (false).
        Parameters:
        newRequired - Whether the parameter is required (true) or optional (false).
      • getPossibleValues

        public Collection getPossibleValues()
        Getter for possibleValues: A list of possible values for value, or null if the possible values is not a closed set.
        Returns:
        A list of possible values for value, or null if the possible values is not a closed set.
      • setPossibleValues

        public Parameter setPossibleValues​(Collection newPossibleValues)
        Setter for possibleValues: A list of possible values for value, or null if the possible values is not a closed set.
        Parameters:
        newPossibleValues - A list of possible values for value, or null if the possible values is not a closed set.
      • getPossibleValuesArray

        public Object[] getPossibleValuesArray()
        Array getter for possibleValues: A list of possible values for value, or null if the possible values is not a closed set.
        Returns:
        An array of possible values for value, or null if the possible values is not a closed set.
      • addPossibleValue

        public void addPossibleValue​(Object value)
        Add a value to possibleValues.
        Parameters:
        value - The possible value to add.
      • extractValue

        public Object extractValue​(Object bean)
        Sets the value of the parameter with the value of the attribute named after name of the given bean.

        e.g. if the parameter's name is "foo" and the bean has a getter called "getFoo()", then the effect of this method is the same as invoking setValue(bead.getFoo()), if the value is not null.

        Parameters:
        bean - The object whose bean attribute should be set.
        Returns:
        The value that was set.
      • toString

        public String toString()
        String representation of the parameter.
        Overrides:
        toString in class Object
        Returns:
        String representation of the parameter.