Annotation Type Property
@Retention(CLASS)
@Target({TYPE,ANNOTATION_TYPE})
@Repeatable(RepeatableProperty.class)
public @interface 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
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 -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean[]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.Class<?> String[]Returns the property value(s).String[]Deprecated.
-
Element Details
-
name
String nameReturns the property name.- Returns:
- this property name
-
value
String[] valueReturns the property value(s). The property value(s) is (are) parsed using thevalueOfmethod of the class specified in the #type attribute (which isStringby 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 thetype()attribute (String by default).- Returns:
- this property value(s).
- Default:
{}
-
type
Class<?> type- Default:
java.lang.String.class
-
longValue
long[] longValueA Long value or an array of Long values.- Returns:
- the long value(s).
- Default:
{}
-
doubleValue
double[] doubleValueA Double value or an array of Double values.- Returns:
- the double value(s).
- Default:
{}
-
floatValue
float[] floatValueA Float value or an array of Float values.- Returns:
- the float value(s).
- Default:
{}
-
intValue
int[] intValueAn Integer value or an array of Integer values.- Returns:
- the int value(s).
- Default:
{}
-
byteValue
byte[] byteValueA Byte value or an array of Byte values.- Returns:
- the byte value(s).
- Default:
{}
-
charValue
char[] charValueA Character value or an array of Character values.- Returns:
- the char value(s).
- Default:
{}
-
booleanValue
boolean[] booleanValueA Boolean value or an array of Boolean values.- Returns:
- the boolean value(s).
- Default:
{}
-
shortValue
short[] shortValueA Short value or an array of Short values.- Returns:
- the short value(s).
- Default:
{}
-
values
String[] valuesDeprecated.usevalue()attribute.Returns an array of property values. The property value are parsed using thevalueOfmethod of the class specified in the #type attribute (which isStringby default).- Returns:
- an array of property values.
- Default:
{}
-
value()attribute.