protected AnnotationDescrBuilderImpl(P parent, String name) { super( parent, new AnnotationDescr( name ) ); }
/** * 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 ); }
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; }
if( buildDescr ) { result = inDescrBuilder != null ? (AnnotationDescr) inDescrBuilder.newAnnotation( n ).getDescr() : new AnnotationDescr( n ); }