Annotation Interface Property


@Target({}) public @interface Property
The definition of a configuration property in a ConfigurationDescription.

When a property is declared in a configuration description of a component, the configuration (in the form of a Properties-object) that is received by an instance of that component always contains a value for that property. This value was either explicitly set in the configuration or it's the default value assigned to the property.

A property is either required or a default value that matches the type and the restrictions of the property must be specified. The default default value is the empty string, so omitting the default value of an optional property may work where it fits the type and restrictions.

TODO: Where to use the description? Add it to the exception message in case of illegal property values? Might also be used in a graphical configuration tool (if we should ever get one).

Author:
Patrick Schmidt
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The supported data types for
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the property, e.g.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether an empty string as default value is to be interpreted as null.
    The default value of the property.
    A short description of the component.
    boolean
    Whether the configuration description is only for documentation purpose, that is, it should be part of the generated configuration documentation but it should not be considered within the actual configuration.
    boolean
    Whether the property is required in configurations.
    Further restrictions on the allowed values of a property.
    See Property.Type for more information on which string values are legal string representations of the respective type.
  • Element Details

    • name

      String name
      The name of the property, e.g. isCaching.
      Returns:
      name of the property
    • description

      String description
      A short description of the component.
      Returns:
      short description of the component
      Default:
      ""
    • isRequired

      boolean isRequired
      Whether the property is required in configurations. Otherwise the defaultValue() will be used (i.e. it will be transparently filled into the configuration of the component.

      Please note, in case of Property.Type.STRING, a required property also means the value must be non-empty!

      Returns:
      whether the property is required in configurations
      Default:
      false
    • type

      See Property.Type for more information on which string values are legal string representations of the respective type.
      Returns:
      the data type of the property
      Default:
      STRING
    • defaultValue

      String defaultValue
      The default value of the property. If isRequired() is set to true the defaultValue is ignored. Otherwise it has to be a legal string representation of the type defined in type(). If the property is not required and no default value is provided, the empty string will be used, that is, the empty string is the default for the default value.
      Returns:
      The default value of the property.
      Default:
      ""
    • defaultNull

      boolean defaultNull
      Whether an empty string as default value is to be interpreted as null. This attribute is only relevant in case the default value is set to the empty string (or not provided at all).
      Returns:
      Whether an empty string as default should be interpreted as null instead of the empty string.
      Default:
      false
    • documentationOnly

      boolean documentationOnly
      Whether the configuration description is only for documentation purpose, that is, it should be part of the generated configuration documentation but it should not be considered within the actual configuration. For instance, the configuration of component/service types and instances should be documented but cannot be retrieved from the static configuration description.
      Default:
      false
    • restrictions

      String[] restrictions
      Further restrictions on the allowed values of a property. Restrictions are expressed through strings of the format: <restrictionType>: <restrictionData> or <restrictionType>/<restrictionOptions>: <restrictionData>. The following restriction types are available:
      • oneof: a comma-separated list of allowed values. Whitespace around the commas is discarded. By default the values are treated case-sensitive. Use i as option for case-insensitive comparisons.
        Example:
        oneof: apple, orange, banana
        oneof/i: apple, orange, banana (case-insensitive comparison)
      • length: a restriction on the length of values, either a fixed length or a range. x can be used as a wildcard.
        Examples:
        length: 5 (a fixed length)
        length: 1 to 6
        length: 1 to x (minimum length of 1 and no maximum length)
      • pattern: a regular expression the values have to match. Leading and trailing whitespace around the pattern is ignored; use parentheses if it's important. By default the pattern matching is case-sensitive. Use i as option for case-insensitive matching.
        Example:
        pattern: prefix.*
        See Pattern for more information an regular expression patterns in Java.
      • range: an interval of allowed values (only available for number types). x can be used as a wildcard. Intervals may be open (( or closed ([) (closed is default if omitted).
        Examples:
        range: 1 to 6 (values between 1 and 6, boundaries included)
        range: [1 to 6] (equal to previous example)
        range: 0 to 1) (values between 0 and 1, right boundary not included)
        range: 5 to x (minimum of 5, no maximum)
        range: x to 8 (maximum of 8, no minimum)
      Returns:
      further restrictions on the allowed values of a property
      Default:
      {}