Interface Parameter<T>

Type Parameters:
T - the type of the parameter
All Superinterfaces:
Named
All Known Subinterfaces:
EnumeratedParameter<T>, NumericParameter<T>, SampledParameter<T>
All Known Implementing Classes:
AbstractParameter, Constant, Enumeration, SampledDouble, SampledInteger, SampledLong

public interface Parameter<T> extends Named
Represents a typed parameter.

To support saving and loading parameters from a file, all parameters must implement the encode(Tokenizer) method along with a static decode(Tokenizer, String) method.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    assignValue(TypedProperties sample, T value)
    Assigns the parameter value in the given sample.
    static Parameter<?>
    decode(String line)
    Decodes the string representation of a parameter.
    static Parameter<?>
    decode(Tokenizer tokenizer, String line)
    Decodes the string representation of a parameter.
    encode(Tokenizer tokenizer)
    Encodes this parameter definition in a format suitable for storing in a file.
    named(String name)
    Entry point to using the parameter builder.
    Parses this parameter value from the given string.
    default T
    Reads the parameter value from the given sample.

    Methods inherited from interface org.moeaframework.core.Named

    getName
  • Method Details

    • parse

      T parse(String str)
      Parses this parameter value from the given string.
      Parameters:
      str - the string
      Returns:
      the parameter value
      Throws:
      InvalidParameterException - if the given string is not a valid parameter value
    • encode

      String encode(Tokenizer tokenizer)
      Encodes this parameter definition in a format suitable for storing in a file.
      Parameters:
      tokenizer - the tokenizer
      Returns:
      the string representation
    • readValue

      default T readValue(TypedProperties sample)
      Reads the parameter value from the given sample.
      Parameters:
      sample - the sample
      Returns:
      the parameter value
    • assignValue

      default void assignValue(TypedProperties sample, T value)
      Assigns the parameter value in the given sample.
      Parameters:
      sample - the sample
      value - the value to assign
    • named

      static ParameterBuilder named(String name)
      Entry point to using the parameter builder. This starts by specifying the name, with additional options being configured on the returned builder.
      Parameters:
      name - the parameter name
      Returns:
      the parameter builder
    • decode

      static Parameter<?> decode(String line)
      Decodes the string representation of a parameter.
      Parameters:
      line - the string representation
      Returns:
      the decoded parameter
      Throws:
      InvalidParameterException - if the string representation is not a valid parameter
    • decode

      static Parameter<?> decode(Tokenizer tokenizer, String line)
      Decodes the string representation of a parameter.
      Parameters:
      tokenizer - the tokenizer
      line - the string representation
      Returns:
      the decoded parameter
      Throws:
      InvalidParameterException - if the string representation is not a valid parameter