Class Distribution.Parameter

java.lang.Object
common.distributions.Distribution.Parameter
All Implemented Interfaces:
Cloneable
Enclosing class:
Distribution

public class Distribution.Parameter extends Object implements Cloneable
This class describes a parameter. It can be instantiated only by Distribution and its subclassses but will be accessed with public methods
Author:
Bertoli Marco Date: 25-giu-2005 Time: 14.47.12
  • Field Details

    • valueClass

      protected Class<?> valueClass
    • value

      protected Object value
    • name

      protected String name
    • description

      protected String description
    • checker

      protected Distribution.ValueChecker checker
    • directParameter

      protected boolean directParameter
  • Constructor Details

    • Parameter

      public Parameter(String name, String description, Class<?> valueClass, Object defaultValue)
      Constructs a new Parameter object. If a custom check on input values is needed, a call to setValueChecker(ValueChecker checker) method must be performed.
      Parameters:
      name - name of this parameter
      description - brief description of this parameter usage
      valueClass - Class type of value of this parameter
      defaultValue - initial value for this parameter getParameterClasspath() for more details.
    • Parameter

      public Parameter(String name, String description, Class<?> valueClass, Object defaultValue, boolean directParameter)
      Constructs a new Parameter object. If a custom check on input values is needed, a call to setValueChecker(ValueChecker checker) method must be performed.
      Parameters:
      name - name of this parameter
      description - brief description of this parameter usage
      valueClass - Class type of value of this parameter
      defaultValue - initial value for this parameter
      directParameter - indicates if this parameter will be added to the distribution of the parameter object when translating it to XML getParameterClasspath() for more details.
  • Method Details

    • setValueChecker

      public void setValueChecker(Distribution.ValueChecker checker)
      Sets a ValueChecker to check if a parameter's value is in the correct range. If no checks are required do not call this method
      Parameters:
      checker - Instance of ValueChecker Interface
    • getValueChecker

      public Distribution.ValueChecker getValueChecker()
      Gets a ValueChecker to check if a parameter's value is in the correct range. If no checks are required do not call this method
      Returns:
      checker Instance of ValueChecker Interface
    • setValue

      public boolean setValue(Object value)
      Sets value for this parameter. Returns if parameter could be assigned correctly
      Parameters:
      value - value to be assigned to this parameter
      Returns:
      If value.class is different from valueClass, or parameter value is not valid, returns false, otherwise true
    • setValue

      public boolean setValue(Object[][] value)
      Sets value for this parameter. Returns if parameter could be assigned correctly
      Parameters:
      value - value to be assigned to this parameter
      Returns:
      If value.class is different from valueClass, or parameter value is not valid, returns false, otherwise true
    • setValue

      public boolean setValue(String value)
      Sets value for this parameter. If parameter class is String sets it, otherwise try to parse string if parameter is of a known numeric type. Returns if parameter could be assigned correctly.
      Parameters:
      value - to be assigned to this parameter or to be parsed
      Returns:
      If value.class is different from valueClass, or parameter value is not parsable or valid, returns false, otherwise true
    • parseValue

      public Object parseValue(String value)
      Parses string if parameter is of a known numeric type.
      Parameters:
      value - value to be parsed
      Returns:
      If value.class is different from valueClass, or parameter value is not parsable, returns null, otherwise number
    • getValue

      public Object getValue()
      Gets this parameter's value
      Returns:
      this parameter's value
    • getValueClass

      public Class<?> getValueClass()
      Gets this parameter value's class, ie the class of which parameter value is instance of.
      Returns:
      parameter value's class
    • getDescription

      public String getDescription()
      Gets a brief description of this parameter, used on distributionpanel
      Returns:
      parameter's description
    • getName

      public String getName()
      Gets the name of this parameter
      Returns:
      this parameter's name
    • isDirectParameter

      public boolean isDirectParameter()
      Returns if this parameter has to be added directly to the distribution when translating it into XML
      Returns:
      true if the parameter has to be added to the distribution. false otherwise
    • clone

      public Object clone()
      Returns a shallow copy of this Parameter. Note that as nothing can be inferred about all values clonability, so parameters are only referenced and not cloned. This should not be a problem as every value should be an immutable type.
      Overrides:
      clone in class Object
      Returns:
      a copy of this parameter