@Override protected String[] defaultSelectedEnums() { return new String[] { RetentionPolicy.CLASS.name() }; } }
@Override protected String[] defaultSelectedEnums() { return new String[] { RetentionPolicy.CLASS.name() }; } }
public boolean retainInBytecode() { List<IAnnotationInfo> annotations = _container.getTypeInfo().getAnnotationsOfType( JavaTypes.getJreType( Retention.class ) ); if( annotations != null ) { for( IAnnotationInfo annotationInfo : annotations ) { String fieldValue = (String) annotationInfo.getFieldValue( "value" ); if( !fieldValue.equals( RetentionPolicy.SOURCE.name() ) ) { return true; } } } return false; }
private boolean hasRetentionPolicy(RetentionPolicy policy) { List<IAnnotationInfo> annotation = _type.getTypeInfo().getAnnotationsOfType( TypeSystem.get(Retention.class) ); if( annotation != null ) { for( IAnnotationInfo annotationInfo : annotation ) { String value = (String) annotationInfo.getFieldValue("value"); if( value.equals(policy.name()) ) { return true; } } } return false; }
private boolean hasRetentionPolicy(RetentionPolicy policy) { List<IAnnotationInfo> annotation = _type.getTypeInfo().getAnnotationsOfType( TypeSystem.get(Retention.class) ); if( annotation != null ) { for( IAnnotationInfo annotationInfo : annotation ) { String value = (String) annotationInfo.getFieldValue("value"); if( value.equals(policy.name()) ) { return true; } } } return false; }
private boolean isSourceAnnotation() { List<IAnnotationInfo> annotations = _type.getTypeInfo().getAnnotationsOfType( JavaTypes.getJreType(Retention.class) ); if( annotations != null ) { for( IAnnotationInfo annotationInfo : annotations ) { String fieldValue = (String) annotationInfo.getFieldValue( "value" ); if( fieldValue.equals( RetentionPolicy.SOURCE.name() ) ) { return true; } } } return false; }
private boolean hasRetentionPolicy( IAnnotationInfo annotation, RetentionPolicy policy ) { List<IAnnotationInfo> annotationsOfType = annotation.getType().getTypeInfo().getAnnotationsOfType( TypeSystem.get( Retention.class ) ); for( IAnnotationInfo retention : annotationsOfType ) { if( retention != null && retention.getFieldValue( "value" ).equals( policy.name() ) ) { return true; } } return false; }
private boolean isSourceAnnotation() { List<IAnnotationInfo> annotations = _type.getTypeInfo().getAnnotationsOfType( JavaTypes.getJreType(Retention.class) ); if( annotations != null ) { for( IAnnotationInfo annotationInfo : annotations ) { String fieldValue = (String) annotationInfo.getFieldValue( "value" ); if( fieldValue.equals( RetentionPolicy.SOURCE.name() ) ) { return true; } } } return false; }
private boolean hasRetentionPolicy( IAnnotationInfo annotation, RetentionPolicy policy ) { List<IAnnotationInfo> annotationsOfType = annotation.getType().getTypeInfo().getAnnotationsOfType( TypeSystem.get( Retention.class ) ); for( IAnnotationInfo retention : annotationsOfType ) { if( retention != null && retention.getFieldValue( "value" ).equals( policy.name() ) ) { return true; } } return false; }
@Override public final void saveIn(Path directory) { try { final String targetsLiteral = this.targets .map(ElementType::name) .collect(Collectors.joining(", ", "{", "}")); final AnnotationSpec retention = AnnotationSpec.builder(Retention.class) .addMember("value", "$L", this.retentionPolicy) .build(); final AnnotationSpec target = AnnotationSpec.builder(Target.class) .addMember("value", "$L", targetsLiteral) .build(); final TypeSpec typeSpec = TypeSpec.annotationBuilder(className) .addModifiers(Modifier.PUBLIC) .addAnnotation(retention) .addAnnotation(target) .build(); JavaFile.builder(packageName, typeSpec) .addStaticImport(RetentionPolicy.class, retentionPolicy.name()) .addStaticImport(ElementType.class, "*") .build().writeTo(directory); } catch(Exception ex) { throw new RuntimeException(ex); } } }