根据the JvmTypesBuilder documentation ,我使用需要使用 toAnnotation(EObject sourceElement, Class type, Object value)
我不明白我应该在那里放什么值?因为我有一个注释 w
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface OResultInfo {
String rowNames() default "";
String columnNames() default "";
String keyNames() default "";
}
我完全不知道如何设置这些值。也许有一些关于java注释的东西我不知道/理解?
最佳答案
您需要使用
val jvmAnnotation = toAnnotation(EObject sourceElement, Class type)
并创建并添加每个值的注释值,并将其分配给 jvmAnnotationReference:
val annotationValue = TypesFactory.eInstance.createJvmStringAnnotationValue();
annotationValue.getValues().add(value);
annotationValue.setOperation(annotationTypesOperation); //i.e. the JvmOperation representing rowNames(), columnNames() or keyNames()
jvmAnnotation.getValues().add(annotationValue);
关于java - 如何使用 xtend 设置 java 注释的多个属性(使用 xbase),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18062449/