java.lang.Object
org.bzdev.obnaming.Parm
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 Summary
ConstructorsConstructorDescriptionParm
(String name, Class<? extends RandomVariable<?>> rvClass, ParmParser parser, Class type) Constructor in non-append mode.Parm
(String name, Class rvClass, ParmParser parser, Class type, Number glb, boolean lbClosed, Number lub, boolean ubClosed) Constructor in non-append mode.Constructor for keyed types.Parm
(String name, Object keyType, Class rvClass, ParmParser parser, Class type, Number glb, boolean lbClosed, Number lub, boolean ubClosed) Constructor for keyed types with bounds.Parm
(String name, ParmParser parser) Constructor for a parameter used only to clear a compound parameter. -
Method Summary
Modifier and TypeMethodDescriptionGet the parameter parser.boolean
Determine if this Parm instance supports clear methods, but not add or set.protected void
Assert that this parm parser is a clear-only parm parser.
-
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 parameterrvClass
- the class of a random variable if values of typetype
are generated by a random variable; false otherwiseparser
- the parser for the parametertype
- 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 parameterrvClass
- the class of a random variable if values of typetype
are generated by a random variable; null otherwiseparser
- the parser for the parameter (each parser may be associated with only one Parm object)type
- the type of the parameterglb
- 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 nulllub
- 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'sclear()
method, which must remove the entries for all keys that match the name- Parameters:
name
- the name of the parameterkeyType
- 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 entryrvClass
- the class of a random variable if values of typetype
are generated by a random variable; false otherwiseparser
- 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
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 parameterparser
- 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'sclear()
method, which must remove the entries for all keys that match the name- Parameters:
name
- the name of the parameterkeyType
- 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 entryrvClass
- the class of a random variable if values of typetype
are generated by a random variable; false otherwiseparser
- the parser for the parameter (each parser may be associated with only one Parm object)type
- the type of the parameterglb
- 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 nulllub
- 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
Get the parameter parser.- Returns:
- the parser
-