Annotation Type PrimitiveParm


@Retention(CLASS) @Target(FIELD) public @interface PrimitiveParm
Annotation to denote a primitive field in a factory. When the field is a Set, the set's type parameter can be a named-object type, an Integer, a String, or an Enumeration. In this case the factory is configured by using 'add' methods, which add entries to a set.

Otherwise the factory is configure using 'set' methods, and the type of the field being annotated is constrained based on the value of the rvmode() element. When rvmode() is false, the type of the field must be boolean, int, double, long, String, BooleanRandomVariable, IntegerRandomVariable, LongRandomVariable DoubleRandomVariable , an enumeration type or a named-object type or a Set whose type parameter is Integer, Double, Long, String, an enumeration type, or the type of a named object. When rvmode is true, the type of the field must be BooleanRandomVariable, IntegerRandomVariable, LongRandomVariable, DoubleRandomVariable, BooleanRandomVariableRV<BRV extends BooleanRandomVariable>, IntegerRandomVariableRV<IRV extends IntegerRandomVariable>, LongRandomVariableRV<LRV extends LongRandomVariable> or DoubleRandomVariableRV<DRV extends DoubleRandomVariable>. When rvmode() is false, the value used is the value of the field. When rvmode() is true, the value used is the value returned by the field's next() method.

The field's declaration must initialize the field with its default value.

When this annotation is used, the corresponding Parm object is also created as part of the ParmManager<T extends NamedObjectFactory> that will be generated. For example

    @FactoryParmManager("OurFactoryParmManager")
    public class OurFactory extends ... {
       @PrimitiveParm("size")
       int size = 10;
       @PrimitiveParm("base")
       int base = 0;
       ...
    }
 
will define parameters named size and base that can be set.
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the parameter.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The lower bound for a parameter's value; the string "null" if there is none.
    boolean
    A boolean that is true if the lower bound is included in the parameter's range; false if it is not.
    boolean
    The parameter's random-variable mode.
    The upper bound for a parameter's value; the string "null" if there is none.
    boolean
    A boolean that is true if the upper bound is included in the parameter's range; false if it is not.
  • Element Details

    • value

      String value
      The name of the parameter.
      Returns:
      the parameter name
    • rvmode

      boolean rvmode
      The parameter's random-variable mode. When false, the type of the parameter is the type of the field being annotated. When true, the type of the field being annotated must be a random-variable type and the type of the parameter is the type of the object that the random-variable produces when its next() method must be called to obtain the value when the field is used to initialize an object. The type of the parameter, when rvmode() is true, will be one of the primitive types int, double, long, or boolean when the field is a subclass of IntegerRandomVariable, DoubleRandomVariable, LongRandomVariable, or BooleanRandomVariable respectively. The type of the parameter, again when rvmode() is true, will be a random variable of the type generated by the field's type when the type of the field is a random variable that generates other random variables. Specifically, when the rvmode() is true and the type of the field is a random variable that generates other random variables, the type of the random variable generated must be IntegerRandomVariable, DoubleRandomVariable, LongRandomVariable, or BooleanRandomVariable.

      From a user's viewpoint,

      • When rvmode() is false, the value is simply used as is, perhaps with some type conversions. For example, if the field is a random variable, a number will be converted to a random variable that repeats the same value, but in either case the field's value will be used to configure the object. Similarly, if a field is an integer, and that field is set to a random number, the random number's next() method will be called when set is called, and the number produced will be the one used to configure the factory, after which all objects created with the factory will use the same value for that field until the factory configuration for that field is changed.
      • When rvmode() is true, for each object created, the factory will obtain the next value of a random variable and use that to configure an object. This is useful primarily with factory methods that create arrays of random variables, where one wants each object to have a different value (the factory must be explicitly coded to call the random variable's next() method to do this).
      Returns:
      the random-variable mode
      Default:
      false
    • upperBound

      String upperBound
      The upper bound for a parameter's value; the string "null" if there is none.
      Returns:
      the upper bound
      Default:
      "null"
    • upperBoundClosed

      boolean upperBoundClosed
      A boolean that is true if the upper bound is included in the parameter's range; false if it is not.
      Returns:
      true if the upper bound is included in the parameter's range; false if it is not
      Default:
      true
    • lowerBound

      String lowerBound
      The lower bound for a parameter's value; the string "null" if there is none.
      Returns:
      the lower bound
      Default:
      "null"
    • lowerBoundClosed

      boolean lowerBoundClosed
      A boolean that is true if the lower bound is included in the parameter's range; false if it is not.
      Returns:
      true if the lower bound is included in the parameter's range; false if it is not.
      Default:
      true