protected void processMetadataAnnotations(Pattern pattern, Map<String, AnnotationDescr> annotationMap) { for ( String key : annotationMap.keySet() ) { if ( ! Pattern.ATTR_LISTENED_PROPS.equals( key ) ) { AnnotationDescr ann = annotationMap.get( key ); AnnotationDefinition def = new AnnotationDefinition( key ); for ( String propKey : ann.getValues().keySet() ) { def.getValues().put( propKey, new AnnotationDefinition.AnnotationPropertyVal( propKey, null, ann.getValue( propKey ), null ) ); } pattern.getAnnotations().put( key, def ); } } }
/** * Assigns a new annotation to this type with the respective name and value * @param name * @param value * @return returns the previous value of this annotation */ public AnnotationDescr addAnnotation( String name, String value ) { if ( this.annotations == null ) { this.annotations = new HashMap<String, AnnotationDescr>(); } AnnotationDescr annotation = new AnnotationDescr( name, value ); return this.annotations.put( annotation.getName(), annotation ); }
/** * 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 Object getValueStripped() { Object single = getSingleValueStripped(); if( single != null ) return single; Map<String,String> sMap = new HashMap<String,String>(); for( Map.Entry<String,String> entry: this.values.entrySet() ){ sMap.put( entry.getKey(), unquote( entry.getValue() ) ); } return sMap; }
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 ); } } }
AnnotationDescr annotation = typeDeclarationDescr.getAnnotation( annotationName ); annotations.put( annotationName, annotation.getValues() );
interfaces ); def.setTraitable( traitable, traitableAnn != null && traitableAnn.getValue( "logical" ) != null && Boolean.valueOf( traitableAnn.getValue( "logical" ) ) ); try { AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation, typeDescr.getAnnotations().get( annotationName ).getValueMap(), pkgRegistry.getTypeResolver() ); def.addAnnotation( annotationDefinition ); def.addMetaData( annotationName, typeDescr.getAnnotation( annotationName ).getSingleValue() );
try { AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation, field.getAnnotations().get( annotationName ).getValueMap(), pkgRegistry.getTypeResolver() ); fieldDef.addAnnotation( annotationDefinition ); fieldDef.addMetaData( annotationName, field.getAnnotation( annotationName ).getSingleValue() );
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; }
public AnnotationDescrBuilder<P> keyValue( String key, String value ) { descr.setKeyValue( key, value ); return this; }
protected AnnotationDescrBuilderImpl(P parent, String name) { super( parent, new AnnotationDescr( name ) ); }
for (String propertyName : listenedProps.getValue().toString().split(",")) { propertyName = propertyName.trim(); if (propertyName.equals("*") || propertyName.equals("!*")) {
/** * Assigns a new annotation to this type * @param annotation * @return returns the previous value of this annotation */ public AnnotationDescr addAnnotation( AnnotationDescr annotation ) { if ( this.annotations == null ) { this.annotations = new HashMap<String, AnnotationDescr>(); } return this.annotations.put( annotation.getName(), annotation ); }
AnnotationDescr annotation = typeDeclarationDescr.getAnnotation( annotationName ); annotations.put( annotationName, annotation.getValues() );
public final void annotationElementValuePair(AnnotationDescr descr) throws RecognitionException { Token key=null; DRLExpressions.annotationValue_return val = null; try { // src/main/resources/org/drools/lang/DRLExpressions.g:201:3: (key= ID EQUALS_ASSIGN val= annotationValue ) // src/main/resources/org/drools/lang/DRLExpressions.g:201:5: key= ID EQUALS_ASSIGN val= annotationValue { key=(Token)match(input,ID,FOLLOW_ID_in_annotationElementValuePair1023); if (state.failed) return ; match(input,EQUALS_ASSIGN,FOLLOW_EQUALS_ASSIGN_in_annotationElementValuePair1025); if (state.failed) return ; pushFollow(FOLLOW_annotationValue_in_annotationElementValuePair1029); val=annotationValue(); state._fsp--; if (state.failed) return ; if ( state.backtracking==0 ) { if ( buildDescr ) { descr.setKeyValue( (key!=null?key.getText():null), (val!=null?input.toString(val.start,val.stop):null) ); } } } } catch (RecognitionException re) { throw re; } finally { } return ; } // $ANTLR end "annotationElementValuePair"
if( buildDescr ) { result = inDescrBuilder != null ? (AnnotationDescr) inDescrBuilder.newAnnotation( n ).getDescr() : new AnnotationDescr( n ); }
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; }
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) {