final String propType = PROPERTY_VALUE_PROCESSING[index]; final String propName = PROPERTY_VALUE_PROCESSING[index + 1]; final Object propValue = ad.getValue(propName); if (propValue != null && propValue.getClass().isArray()) { type = propType; String name = ad.getStringValue("name", null); prop.setLabel(ad.getStringValue("label", null)); prop.setDescription(ad.getStringValue("description", null)); if ( ad.getValue("propertyPrivate") != null ) { prop.setPrivate(ad.getBooleanValue("propertyPrivate", false)); .valueOf(ad.getEnumValue("unbounded", PropertyUnbounded.DEFAULT.name())); prop.setUnbounded(pu); prop.setCardinality(ad.getIntegerValue("cardinality", 0)); if (prop.getMultiValue() != null && prop.getCardinality() == 0) { prop.setUnbounded(PropertyUnbounded.ARRAY); final ScannedAnnotation[] options = (ScannedAnnotation[])ad.getValue("options"); if (options != null) { final List<String> propertyOptions = new ArrayList<String>(); for(final ScannedAnnotation po : options) { propertyOptions.add(po.getStringValue("name", "")); propertyOptions.add(po.getStringValue("value", ""));
ref.setName(ad.getStringValue("name", (fieldAnnotation != null ? fieldAnnotation.getAnnotatedField().getName() : null))); String defaultInterfaceName = null; ref.setInterfaceName(ad.getStringValue("referenceInterface", defaultInterfaceName)); ref.setTarget(ad.getStringValue("target", null)); ref.setCardinality(ReferenceCardinality.valueOf(ad.getEnumValue("cardinality", ReferenceCardinality.MANDATORY_UNARY.name()))); ref.setPolicy(ReferencePolicy.valueOf(ad.getEnumValue("policy", ReferencePolicy.STATIC.name()))); ref.setPolicyOption(ReferencePolicyOption.valueOf(ad.getEnumValue("policyOption", ReferencePolicyOption.RELUCTANT.name()))); ref.setStrategy(ReferenceStrategy.valueOf(ad.getEnumValue("strategy", ReferenceStrategy.EVENT.name()))); ref.setBind(ad.getStringValue("bind", null)); ref.setUnbind(ad.getStringValue("unbind", null)); ref.setUpdated(ad.getStringValue("updated", null));
/** * Get a boolean value of the annotation * @param name The property name * @param defaultValue A default value if the property is not set * @return The property value or the default value. */ public boolean getBooleanValue(final String name, final boolean defaultValue) { final Object val = this.getValue(name); if ( val != null ) { return ((Boolean) val).booleanValue(); } return defaultValue; }
/** * Get all class annotations * @param name The name of the class annotation or <code>null</code> * for all class annotations. * @return A list of matching annotations or an empty list. */ public List<ClassAnnotation> getClassAnnotations(final String name) { final List<ClassAnnotation> list = new ArrayList<ClassAnnotation>(); for(final ScannedAnnotation desc : descriptions ) { if ( desc instanceof ClassAnnotation ) { if ( name == null || desc.getName().equals(name) ) { list.add( (ClassAnnotation)desc); } } } return list; }
/** * Create a new abstract description * @param annotation The corresponding annotation. */ public AbstractDescription(final ScannedAnnotation annotation) { this.annotation = annotation; if ( annotation == null ) { this.annotationPrefix = ""; } else { this.annotationPrefix = "@" + annotation.getSimpleName(); } this.sourceLocation = "<unknown>"; }
/** * Get an integer value of the annotation * @param name The property name * @param defaultValue A default value if the property is not set * @return The property value or the default value. */ public int getIntegerValue(final String name, final int defaultValue) { final Object val = this.getValue(name); if ( val != null ) { return ((Integer) val).intValue(); } return defaultValue; }
/** * Get all field annotations * @param name The name of the field annotation or <code>null</code> * for all field annotations. * @return A list of matching annotations or an empty list. */ public List<FieldAnnotation> getFieldAnnotations(final String name) { final List<FieldAnnotation> list = new ArrayList<FieldAnnotation>(); for(final ScannedAnnotation desc : descriptions ) { if ( desc instanceof FieldAnnotation ) { if ( name == null || desc.getName().equals(name) ) { list.add( (FieldAnnotation)desc); } } } return list; }
/** * Get a long value of the annotation * @param name The property name * @param defaultValue A default value if the property is not set * @return The property value or the default value. */ public long getLongValue(final String name, final long defaultValue) { final Object val = this.getValue(name); if ( val != null ) { return ((Long) val).intValue(); } return defaultValue; }
/** * Get all method annotations * @param name The name of the method annotation or <code>null</code> * for all method annotations. * @return A list of matching annotations or an empty list. */ public List<MethodAnnotation> getMethodAnnotations(final String name) { final List<MethodAnnotation> list = new ArrayList<MethodAnnotation>(); for(final ScannedAnnotation desc : descriptions ) { if ( desc instanceof MethodAnnotation ) { if ( name == null || desc.getName().equals(name) ) { list.add( (MethodAnnotation)desc); } } } return list; } }
/** * Get an enumeration value of the annotation * @param name The property name * @param defaultValue A default value if the property is not set * @return The property value or the default value. */ public String getEnumValue(final String name, final String defaultValue) { final Object val = this.getValue(name); if ( val != null ) { if ( val instanceof String[] ) { return ((String[])val)[1]; } if ( val instanceof String[][] ) { return ((String[][])val)[0][1]; } return val.toString(); } return defaultValue; }
/** * Get a string value of the annotation * @param name The property name * @param defaultValue A default value if the property is not set * @return The property value or the default value. */ public String getStringValue(final String name, final String defaultValue) { final Object val = this.getValue(name); if ( val != null && val.toString().trim().length() > 0 ) { return val.toString().trim(); } return defaultValue; }