當前位置: 首頁>>代碼示例>>Java>>正文


Java JFieldVar.annotations方法代碼示例

本文整理匯總了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));
  		}
}
  }
 
開發者ID:phoenixnap,項目名稱:springmvc-raml-plugin,代碼行數:15,代碼來源:RamlInterpreterTest.java

示例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;
  }
 
開發者ID:phoenixnap,項目名稱:springmvc-raml-plugin,代碼行數:13,代碼來源:RamlInterpreterTest.java

示例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"));
                }
            }
        }
    }
}
 
開發者ID:massfords,項目名稱:jaxb-visitor,代碼行數:25,代碼來源:ClassDiscoverer.java

示例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);
		}
	}
}
 
開發者ID:destin,項目名稱:SO-answers,代碼行數:10,代碼來源:NullableNillablePlugin.java


注:本文中的com.sun.codemodel.JFieldVar.annotations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。