/** * Returns the metadata value as a single object or a Map * @return */ public Object getValue() { Object single = getSingleValue(); return single != null ? single : this.values; }
public FieldDescrBuilder processAnnotations() { if ( descr.getAnnotations().containsKey( TypeDeclaration.ATTR_FIELD_POSITION ) ) { int pos = Integer.valueOf(descr.getAnnotation( TypeDeclaration.ATTR_FIELD_POSITION ).getSingleValue()); descr.setIndex(pos); } return this; }
fieldDef.addMetaData( annotationName, field.getAnnotation( annotationName ).getSingleValue() );
public void buildMetaAttributes(final RuleBuildContext context ) { Rule rule = context.getRule(); for ( String metaAttr : context.getRuleDescr().getAnnotationNames() ) { AnnotationDescr ad = context.getRuleDescr().getAnnotation( metaAttr ); if ( ad.hasValue() ) { if ( ad.getValues().size() == 1 ) { rule.addMetaAttribute( metaAttr, resolveValue( ad.getSingleValue() ) ); } else { rule.addMetaAttribute( metaAttr, ad.getValueMap() ); } } else { rule.addMetaAttribute( metaAttr, null ); } } }
protected TypeFieldDescr buildInheritedFieldDescrFromDefinition( FactField fld, TypeDeclarationDescr typeDescr ) { PatternDescr fldType = new PatternDescr(); TypeFieldDescr inheritedFldDescr = new TypeFieldDescr(); inheritedFldDescr.setFieldName( fld.getName() ); fldType.setObjectType( ( (FieldDefinition) fld ).getFieldAccessor().getExtractToClassName() ); inheritedFldDescr.setPattern( fldType ); if ( fld.isKey() ) { inheritedFldDescr.getAnnotations().put( TypeDeclaration.ATTR_KEY, new AnnotationDescr( TypeDeclaration.ATTR_KEY ) ); } inheritedFldDescr.setIndex( ( (FieldDefinition) fld ).getDeclIndex() ); inheritedFldDescr.setInherited( true ); String initExprOverride = ( (FieldDefinition) fld ).getInitExpr(); int overrideCount = 0; // only @aliasing local fields may override defaults. for ( TypeFieldDescr localField : typeDescr.getFields().values() ) { AnnotationDescr ann = localField.getAnnotation( "Alias" ); if ( ann != null && fld.getName().equals( ann.getSingleValue().replaceAll( "\"", "" ) ) && localField.getInitExpr() != null ) { overrideCount++; initExprOverride = localField.getInitExpr(); } } if ( overrideCount > 1 ) { // however, only one is allowed initExprOverride = null; } inheritedFldDescr.setInitExpr( initExprOverride ); return inheritedFldDescr; }
def.addMetaData( annotationName, typeDescr.getAnnotation( annotationName ).getSingleValue() );
String role = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (role != null) { type.setRole( TypeDeclaration.Role.parseRole( role ) ); String typesafe = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (typesafe != null) { type.setTypesafe( Boolean.parseBoolean( typesafe ) ); String format = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (format != null) { type.setFormat( TypeDeclaration.Format.parseFormat( format ) ); String kind = (annotationDescr != null) ? annotationDescr.getSingleValue() : null; if ( kind != null ) { type.setKind( TypeDeclaration.Kind.parseKind( kind ) ); String className = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (StringUtils.isEmpty( className )) { className = type.getTypeName();
String timestamp = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (timestamp != null) { type.setTimestampAttribute( timestamp ); String duration = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (duration != null) { type.setDurationAttribute( duration ); String expiration = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null; if (expiration != null) { if (timeParser == null) {