Annotation Type Property


Annotation used to describe a property key-value(s) pair. Such annotation can be applied on components.

Property value(s) type is String by default, and the type is scalar if the value is single-valued, or an array if the value is multi-valued. You can apply this annotation on a component class multiple times (it's a java8 repeatable property). Eight primitive types are supported:

  • String (default type)
  • Long
  • Double
  • Float
  • Integer
  • Byte
  • Boolean
  • Short
You can specify the type of a property either using a combination of value and type attributes, or using one of the longValue/doubleValue/floatValue/intValue/byteValue/charValue/booleanValue/shortValue attributes. Notice that you can also specify service properties dynamically by returning a Map from a method annotated with Start.

Usage Examples

 @Component
 @Property(name="p1", value="v")                      // String value type (scalar)
 @Property(name="p2", value={"s1", "s2"})             // Array of Strings
 @Property(name="service.ranking", intValue=10)       // Integer value type (scalar)
 @Property(name="p3", intValue={1,2})                 // Array of Integers
 @Property(name="p3", value="1", type=Long.class)     // Long value (scalar)
 class ServiceImpl implements Service {
 }
 
Author:
Felix Project Team
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns the property name.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean[]
    A Boolean value or an array of Boolean values.
    byte[]
    A Byte value or an array of Byte values.
    char[]
    A Character value or an array of Character values.
    double[]
    A Double value or an array of Double values.
    float[]
    A Float value or an array of Float values.
    int[]
    An Integer value or an array of Integer values.
    long[]
    A Long value or an array of Long values.
    short[]
    A Short value or an array of Short values.
    Specifies how the value() or values() attributes are parsed.
    Returns the property value(s).
    Deprecated.
    use value() attribute.
  • Element Details

    • name

      String name
      Returns the property name.
      Returns:
      this property name
    • value

      String[] value
      Returns the property value(s). The property value(s) is (are) parsed using the valueOf method of the class specified in the #type attribute (which is String by default). When the property value is single-value, then the value type is scalar (not an array). If the property value is multi-valued, then the value type is an array of the type specified in the type() attribute (String by default).
      Returns:
      this property value(s).
      Default:
      {}
    • type

      Class<?> type
      Specifies how the value() or values() attributes are parsed.
      Returns:
      the property value type (String by default) used to parse value() or values() attribtues
      Default:
      java.lang.String.class
    • longValue

      long[] longValue
      A Long value or an array of Long values.
      Returns:
      the long value(s).
      Default:
      {}
    • doubleValue

      double[] doubleValue
      A Double value or an array of Double values.
      Returns:
      the double value(s).
      Default:
      {}
    • floatValue

      float[] floatValue
      A Float value or an array of Float values.
      Returns:
      the float value(s).
      Default:
      {}
    • intValue

      int[] intValue
      An Integer value or an array of Integer values.
      Returns:
      the int value(s).
      Default:
      {}
    • byteValue

      byte[] byteValue
      A Byte value or an array of Byte values.
      Returns:
      the byte value(s).
      Default:
      {}
    • charValue

      char[] charValue
      A Character value or an array of Character values.
      Returns:
      the char value(s).
      Default:
      {}
    • booleanValue

      boolean[] booleanValue
      A Boolean value or an array of Boolean values.
      Returns:
      the boolean value(s).
      Default:
      {}
    • shortValue

      short[] shortValue
      A Short value or an array of Short values.
      Returns:
      the short value(s).
      Default:
      {}
    • values

      String[] values
      Deprecated.
      use value() attribute.
      Returns an array of property values. The property value are parsed using the valueOf method of the class specified in the #type attribute (which is String by default).
      Returns:
      an array of property values.
      Default:
      {}