Class Parameter<T>

java.lang.Object
de.muehlencord.shared.configuration.Parameter<T>
Type Parameters:
T - type of parameter
Direct Known Subclasses:
BooleanParameter, DateParameter, IntegerParameter, StringParameter, URIParameter

public abstract class Parameter<T> extends Object
Author:
Joern Muehlencord (joern@muehlencord.de)
  • Field Details

    • name

      protected String name
      the name of the parameter
    • description

      protected String description
      the long description of this parameter
    • mandatory

      protected boolean mandatory
      boolean flag if this is a mandatory parameter or not
    • stringConverter

      protected StringConverter<T> stringConverter
      the string converter to convert the object to string and back again
    • requiredParameters

      protected List<Parameter<?>> requiredParameters
      list of mandatory parameters, if this parameter is active
    • validator

      protected Validator<T> validator
      optional validator
    • valueList

      protected List<T> valueList
      optional value list
    • defaultValue

      protected T defaultValue
      the default value
  • Constructor Details

    • Parameter

      public Parameter(String name, StringConverter<T> converter)
      creates a new mandatory string parameter object
      Parameters:
      name - the name of the parameter
      converter - the converter object to convert the value of the parameter to string and vice versa
    • Parameter

      public Parameter(String name, StringConverter<T> converter, boolean mandatory)
      creates a new string parameter object. If the parameter is mandatory or not can be specified.
      Parameters:
      name - the name of the parameter
      converter - the converter object to convert the value of the parameter to string and vice versa
      mandatory - determines if this is a mandatory parameter or not
    • Parameter

      public Parameter(String name, StringConverter<T> converter, String description, boolean mandatory)
      creates a new string parameter object.
      Parameters:
      name - the name of the parameter
      converter - the converter object to convert the value of the parameter to string and vice versa
      description - the long text description of this parameter
      mandatory - determines if this is a mandatory parameter or not
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
      Returns:
      the name
    • getDescription

      public String getDescription()
      Returns:
      the description
    • isMandatory

      public boolean isMandatory()
      Returns:
      the mandatory
    • getStringConverter

      public StringConverter<T> getStringConverter()
      Returns:
      the stringConverter
    • addRequiredParameter

      public void addRequiredParameter(Parameter param)
      adds a parameter to the list of required parameters
      Parameters:
      param - the parameter to add
    • getRequiredParameter

      public List<Parameter<?>> getRequiredParameter()
      returns the list of parameters the given parameter requires
      Returns:
      the list of parameters the given parameter requires
    • setValidator

      public void setValidator(Validator<T> validator)
      Parameters:
      validator - the validator to set
    • addValueList

      public void addValueList(T... values)
    • getValueList

      public List<T> getValueList()
    • getDefaultValue

      public T getDefaultValue()
    • setDefaultValue

      public void setDefaultValue(T defaultValue)
    • isValid

      public boolean isValid(T value)
      returns true, if the given value is part of the possible value list or if the given value list is true
      Parameters:
      value - the value to validate
      Returns:
      true if no value list is defined or value is part of the value list; false otherwise
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object