Annotation Type CompoundParm


@Retention(CLASS) @Target(FIELD) public @interface CompoundParm
Annotation for compound parameters. The object annotated must be a field whose type matches a class that has a CompoundParmType annotation. This class must have a constructor with zero arguments and will have some or all of its fields annotated by a PrimitiveParm annotation. An instance created using a zero-argument constructor must be used in the initializer, which is mandatory. The initial value may use a subclass. For example,
    @CompoundParmType
    class Value {
       @PrimitiveParm("Size")
       int size = 10;
       @PrimitiveParm("Base")
       int base = 0;
    }

    @FactoryParmManager("OurFactoryParmManager")
    public class OurFactory extends ... {
       @CompoundParm("value")
       Value value = new Value();
       ...
    }
 
This will define factory parameters whose names are "value.size" and "value.base" that will be initialized using a method named set. A delimiter is provided, that will be inserted after the string "map" in the name, with a default delimiter ".". If no delimiter is desired, set the delimiter to an empty string. Thus, to set a value, one might use
   OurFactory factory;
   ...
   factory.set("value.base", 10);
   factory.set("value.size", 20);
 

As an example of using a subclass in an initializer

  @CompoundParm("edgeColor")
  ColorParm edgeColor = new ColorParm.RED();
 
will configure edgeColor so its default value produces the color red. By contrast, the definition
  @CompoundParm("edgeColor")
  ColorParm edgeColor = new ColorParm(Color.RED);
 
will result in the color provided by ColorParm's zero-argument constructor, which is not what is desired: whenever edgeColor is reset to its default, the value's constructor will be called.
See Also:
  • Required Element Summary

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

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The delimiter separating the key's name from one of its value's names.
  • Element Details

    • value

      String value
      The name of the key.
      Returns:
      the key name
    • delimiter

      String delimiter
      The delimiter separating the key's name from one of its value's names. The delimiter must not be "."
      Returns:
      the delimiter
      Default:
      "."