Class Parm

java.lang.Object
org.bzdev.obnaming.Parm

public class Parm extends Object
Named-Object-factory parameter. Parameters for a subclass of NamedObjectFactory are referenced by unique names: each parameter that a factory recognizes must have a different name. A factory provides a series of 'set' methods that allow values of parameters to be set. The Parm class describes each parameter.

Keyless parameters are the simplest ones, with appropriate parameters supplied by the constructors Parm(String,Class,ParmParser,Class) and Parm(String,...,Class,Number,boolean,Number,boolean). In the constructor documentation,

  • The name argument is the parameter name, which must be unique among all parameter names for a given factory, including parameters defined in a factory's superclasses.
  • The rvClass argument, if not null, specifies the type of a random variable that will generate a sequence of values whose types are type, one value per object created. When null, the value provided is used as is.
  • The parser argument provides a parser that is responsible for storing a value and clearing the value (which typically means setting the variable to its default value). A parser can be associated with only one instance of Parm.
  • The type defines the type of the value used to create or configure an object.
  • The glb argument provides a greatest lower bound on the value of an argument; null if there is none.
  • The lbClosed argument is true if the greatest lower bound is a value the parameter may have; false otherwise.
  • The lub argument provides a least upper bound on the value of an argument; null if there is none.
  • The ubClosed argument is true if the least upper bound is a value the parameter may have; false otherwise.
  • Constructor Details

    • Parm

      public Parm(String name, Class<? extends RandomVariable<?>> rvClass, ParmParser parser, Class type) throws IllegalStateException
      Constructor in non-append mode.
      Parameters:
      name - the name of the parameter
      rvClass - the class of a random variable if values of type type are generated by a random variable; false otherwise
      parser - the parser for the parameter
      type - the type of the parameter
      Throws:
      IllegalStateException - a parm parser was already in use
    • Parm

      public Parm(String name, Class rvClass, ParmParser parser, Class type, Number glb, boolean lbClosed, Number lub, boolean ubClosed) throws IllegalStateException
      Constructor in non-append mode.
      Parameters:
      name - the name of the parameter
      rvClass - the class of a random variable if values of type type are generated by a random variable; null otherwise
      parser - the parser for the parameter (each parser may be associated with only one Parm object)
      type - the type of the parameter
      glb - the greatest lower bound for the range of acceptable values.
      lbClosed - true if the greatest lower bound is in the range of acceptable values; false if not; ignored if glb is null
      lub - the least upper bound for the range of acceptable values.
      ubClosed - true if the least upper bound is in the range of acceptable values; false if not; ignored if lub is null
      Throws:
      IllegalStateException - a parm parser was already in use
    • Parm

      public Parm(String name, Object keyType, Class rvClass, ParmParser parser, Class type) throws IllegalStateException
      Constructor for keyed types. If both the keyType and type arguments (arguments 2 and 4) are null, the factories "remove" method will call the parser argument's clear() method, which must remove the entries for all keys that match the name
      Parameters:
      name - the name of the parameter
      keyType - the class of a simulation object that can be referenced by name, in which case a the type is a string; String.class for strings, Integer.class for integer indices; an instance of ParmKeyType if a qualified name; null if not a keyed entry
      rvClass - the class of a random variable if values of type type are generated by a random variable; false otherwise
      parser - the parser for the parameter (each parser may be associated with only one Parm object)
      type - the type of the parameter
      Throws:
      IllegalStateException - a parm parser was already in use
    • Parm

      public Parm(String name, ParmParser parser)
      Constructor for a parameter used only to clear a compound parameter. The parser should have only a clear() method implemented explicitly.
      Parameters:
      name - the name of the parameter
      parser - the parser for the parameter (each parser may be associated with only one Parm object)
    • Parm

      public Parm(String name, Object keyType, Class rvClass, ParmParser parser, Class type, Number glb, boolean lbClosed, Number lub, boolean ubClosed) throws IllegalStateException
      Constructor for keyed types with bounds. If both the keyType and type arguments (arguments 2 and 4) are null, the factories "remove" method will call the parser argument's clear() method, which must remove the entries for all keys that match the name
      Parameters:
      name - the name of the parameter
      keyType - the class of a simulation object that can be referenced by name, in which case a the type is a string; String.class for strings, Integer.class for integer indices; an instance of ParmKeyType if a qualified name; null if not a keyed entry
      rvClass - the class of a random variable if values of type type are generated by a random variable; false otherwise
      parser - the parser for the parameter (each parser may be associated with only one Parm object)
      type - the type of the parameter
      glb - the greatest lower bound for the range of acceptable values.
      lbClosed - true if the greatest lower bound is in the range of acceptable values; false if not; ignored if glb is null
      lub - the least upper bound for the range of acceptable values.
      ubClosed - true if the least upper bound is in the range of acceptable values; false if not; ignored if lub is null
      Throws:
      IllegalStateException - a parm parser was already in use
  • Method Details

    • isClearOnly

      public boolean isClearOnly()
      Determine if this Parm instance supports clear methods, but not add or set.
      Returns:
      true if clear methods are supported but not add or set; false otherwise
    • makeClearOnly

      protected void makeClearOnly()
      Assert that this parm parser is a clear-only parm parser.
    • getParser

      public ParmParser getParser()
      Get the parameter parser.
      Returns:
      the parser