2013-08-05 85 views
0

根據the JvmTypesBuilder documentation,我用需要使用toAnnotation(EObject sourceElement, Class type, Object value)如何設置與XTEND一個Java註釋的多個屬性(使用XBASE)

我不明白,我應該把什麼價值呢?因爲我有一個註釋w

@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.METHOD) 
public @interface OResultInfo { 
    String rowNames() default ""; 
    String columnNames() default ""; 
    String keyNames() default ""; 
} 

我完全不知道如何設置這些值。也許有一些關於java註釋我不知道/明白嗎?

回答

1

您需要使用

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); 
相關問題