本文整理匯總了Java中com.sun.codemodel.JFieldVar.annotations方法的典型用法代碼示例。如果您正苦於以下問題:Java JFieldVar.annotations方法的具體用法?Java JFieldVar.annotations怎麽用?Java JFieldVar.annotations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.codemodel.JFieldVar
的用法示例。
在下文中一共展示了JFieldVar.annotations方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkIfFieldContainsAnnotation
import com.sun.codemodel.JFieldVar; //導入方法依賴的package包/類
private void checkIfFieldContainsAnnotation(boolean expected, JDefinedClass classToCheck, Class<?> annotationClass, String... fields) {
for (JFieldVar field : classToCheck.fields().values()) {
if( (fields == null || fields.length == 0 || ArrayUtils.contains(fields, field.name()))
&& !field.name().equals("serialVersionUID")) {
boolean found = false;
for(JAnnotationUse annotation : field.annotations()) {
if (annotation.getAnnotationClass().name().equals(annotationClass.getSimpleName())) {
found = true;
}
}
assertThat(found, is(expected));
}
}
}
示例2: getAnnotationForField
import com.sun.codemodel.JFieldVar; //導入方法依賴的package包/類
private JAnnotationUse getAnnotationForField(JDefinedClass classToCheck, Class<?> annotationClass, String field) {
for (JFieldVar fieldVar : classToCheck.fields().values()) {
if( fieldVar.name().equals(field)) {
for(JAnnotationUse annotation : fieldVar.annotations()) {
if (annotation.getAnnotationClass().name().equals(annotationClass.getSimpleName())) {
return annotation;
}
}
}
}
return null;
}
示例3: parseXmlAnnotations
import com.sun.codemodel.JFieldVar; //導入方法依賴的package包/類
/**
* Parse the annotations on the field to see if there is an XmlElements
* annotation on it. If so, we'll check this annotation to see if it
* refers to any classes that are external from our code schema compile.
* If we find any, then we'll add them to our visitor.
* @param outline root of the generated code
* @param field parses the xml annotations looking for an external class
* @param directClasses set of direct classes to append to
* @throws IllegalAccessException throw if there's an error introspecting the annotations
*/
private static void parseXmlAnnotations(Outline outline, FieldOutline field, Set<String> directClasses) throws IllegalAccessException {
if (field instanceof UntypedListField) {
JFieldVar jfv = (JFieldVar) FieldHack.listField.get(field);
for(JAnnotationUse jau : jfv.annotations()) {
JClass jc = jau.getAnnotationClass();
if (jc.fullName().equals(XmlElements.class.getName())) {
JAnnotationArrayMember value = (JAnnotationArrayMember) jau.getAnnotationMembers().get("value");
for(JAnnotationUse anno : value.annotations()) {
handleXmlElement(outline, directClasses, anno.getAnnotationMembers().get("type"));
}
}
}
}
}
示例4: fixRequiredInXmlElementRef
import com.sun.codemodel.JFieldVar; //導入方法依賴的package包/類
private void fixRequiredInXmlElementRef(JFieldVar jFieldVar) {
Collection<JAnnotationUse> annotations = jFieldVar.annotations();
for (JAnnotationUse annotationUse : annotations) {
if (XmlElementRef.class.equals(annotationUse.getAnnotationClass()
.getClass())) {
annotationUse.param("required", false);
}
}
}