PrimitiveParm
annotation.
When the type of the map's value 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 (with three argument), which add entries to the set corresponding to a key.
Otherwise the factory is configure using three-argument set methods, and
the type of a map's value is dependent on the value of the
rvmode() element. When rvmode() is false, the type of the map's value must
be either Boolean, Integer, Long, Double, String, an enumeration,
the class of a named object,
BooleanRandomVariable
,
IntegerRandomVariable
,
LongRandomVariable
, or
DoubleRandomVariable
.
When rvmode() is true, the type of the map's value must be either
BooleanRandomVariable
,
IntegerRandomVariable
,
LongRandomVariable
,
DoubleRandomVariable
,
BooleanRandomVariableRV<BRV extends BooleanRandomVariable>
,
IntegerRandomVariableRV<IRV extends IntegerRandomVariable>
,
LongRandomVariableRV<LRV extends LongRandomVariable>
, or
DoubleRandomVariableRV<DRV extends DoubleRandomVariable>
.
Please see rvmode()
for a more detailed
description of the rvmode() element.
For example,
This will define factory parameters whose name is "map", whose key is an instance of OurNamedObject, and whose value is a double-precision number. The following example shows the usage for an instance@FactoryParmManager("OurFactoryParmManager") public class OurFactory extends ... { @KeyedPrimitiveParm("map") Map<OurNamedObject,Double> hashmap = new HashMap<>(); ... }
factory
of a class using this annotation:
orfactory.set("map", ourNamedObject, 20.0);
where ourNamedObject is an instance of OurNamedObject with the name "ourObject".factory.set("map", "ourObject", 20.0);
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe lower bound for the map's value; the string "null" if there is none.boolean
A boolean that is true if the lower bound is included in the map's value's range; false if it is not.boolean
The parameter's random-variable mode.The upper bound for the the map's value; the string "null" if there is none.boolean
A boolean that is true if the upper bound is included in the map's value's range; false if it is not.
-
Element Details
-
value
String valueThe name of the parameter.- Returns:
- the parameter name
-
-
-
rvmode
boolean rvmodeThe parameter's random-variable mode. The object being annotated is a map and the rvmode() element applies to that map's value, not its key:- When rvmode() is false, the type of the parameter's value is the type of the map's value.
- When rvmode() is true, the map's value must be a random variable, and the type of this value is based on the type that the will be used as the third argument in the factory's corresponding 'set' method. When the expected type for the third argument for the 'set' method is one of the primitive types int, double, long, or boolean then the type of the value field for the map must be a subclass of IntegerRandomVariable, DoubleRandomVariable, LongRandomVariable, or BooleanRandomVariable respectively. Similarly, when the expected type for the third argument in the factory's corresponding 'set' method is the random-variable types IntegerRandomVariable, DoubleRandomVariable, LongRandomVariable, or BooleanRandomVariable, then the type of the value field for the map must be a IntegerRandomVariableRV, DoubleRandomVariableRV, LongRandomVariableRV, or BooleanRandomVariableRV respectively.
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 (a random number) will be used t configure the object, typically by passing the random number to the object durint the object's initialization.
- When rvmode() is true, for each random number, the factory will obtain its' next value 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 - this behavior does not occur automatically).
- Returns:
- true or false as described above
- Default:
- false
-
upperBound
String upperBoundThe upper bound for the the map's value; the string "null" if there is none. It is ignored for types that are not numbers or random variables that generate numbers.- Returns:
- the upper bound; null if there is none
- Default:
- "null"
-
upperBoundClosed
boolean upperBoundClosedA boolean that is true if the upper bound is included in the map's value's range; false if it is not.- Returns:
- true if the upper bound is in the range; false otherwise
- Default:
- true
-
lowerBound
String lowerBoundThe lower bound for the map's value; the string "null" if there is none. It is ignored for types that are not numbers or random variables that generate numbers.- Returns:
- the lower bound; null if there is none
- Default:
- "null"
-
lowerBoundClosed
boolean lowerBoundClosedA boolean that is true if the lower bound is included in the map's value's range; false if it is not.It is ignored for types that are not numbers or random variables that generate numbers.
- Returns:
- true if the lower bound is included in the map's value's range; false if it is not.
- Default:
- true
-