当前位置: 首页>>代码示例>>Java>>正文


Java TypeElement.getAnnotationMirrors方法代码示例

本文整理汇总了Java中javax.lang.model.element.TypeElement.getAnnotationMirrors方法的典型用法代码示例。如果您正苦于以下问题:Java TypeElement.getAnnotationMirrors方法的具体用法?Java TypeElement.getAnnotationMirrors怎么用?Java TypeElement.getAnnotationMirrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.element.TypeElement的用法示例。


在下文中一共展示了TypeElement.getAnnotationMirrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStateStrategyType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public String getStateStrategyType(TypeElement typeElement) {
	for (AnnotationMirror annotationMirror : typeElement.getAnnotationMirrors()) {
		if (!annotationMirror.getAnnotationType().asElement().toString().equals(STATE_STRATEGY_TYPE_ANNOTATION)) {
			continue;
		}

		final Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = annotationMirror.getElementValues();
		final Set<? extends ExecutableElement> keySet = elementValues.keySet();

		for (ExecutableElement key : keySet) {
			if ("value".equals(key.getSimpleName().toString())) {
				return elementValues.get(key).toString();
			}
		}
	}

	return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ViewStateClassGenerator.java

示例2: isMethodInContainerLookup

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Checks whether is given method declared by no-interface Bean or by interface annotated by
 * {@code @javax.ejb.Remote} or {@code @javax.ejb.Local}
 *
 * @param srcClass class for which are generated test cases
 * @param srcMethod method of interest
 * @return {@code true} if the bean is no-interface or method is declared by
 * respectively annotated interface, {@code false} otherwise
 */
private static boolean isMethodInContainerLookup(TypeElement srcClass, ExecutableElement srcMethod) {
    // check for no-interface LocalBean
    List<? extends AnnotationMirror> annotations = srcClass.getAnnotationMirrors();
    for (AnnotationMirror annotationMirror : annotations) {
        String annotation = ((TypeElement)annotationMirror.getAnnotationType().asElement()).getQualifiedName().toString();
        if (annotation.equals("javax.ejb.LocalBean"))   // NOI18N
            return true;
    }
    // check if the class has empty implements clause or given method is declared by @Remote, @Local interface
    List<? extends TypeMirror> interfaces = srcClass.getInterfaces();
    if (interfaces.isEmpty()
            || areAllowedInterfacesForLocalBean(interfaces)
            || getEjbInterfaceDeclaringMethod(srcMethod, interfaces) != null) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AbstractTestGenerator.java

示例3: isMethodInContainerLookup

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Checks whether is given method declared by no-interface Bean or by interface annotated by
 * {@literal @javax.ejb.Remote} or {@literal @javax.ejb.Local}
 *
 * @param srcClass class for which are generated test cases
 * @param srcMethod method of interest
 * @return {@literal true} if the bean is no-interface or method is declared by
 * respectively annotated interface, {@literal false} otherwise
 */
private static boolean isMethodInContainerLookup(TypeElement srcClass, ExecutableElement srcMethod) {
    // check for no-interface LocalBean
    List<? extends AnnotationMirror> annotations = srcClass.getAnnotationMirrors();
    for (AnnotationMirror annotationMirror : annotations) {
        String annotation = ((TypeElement)annotationMirror.getAnnotationType().asElement()).getQualifiedName().toString();
        if (annotation.equals("javax.ejb.LocalBean"))   // NOI18N
            return true;
    }
    // check if the class has empty implements clause or given method is declared by @Remote, @Local interface
    List<? extends TypeMirror> interfaces = srcClass.getInterfaces();
    if (interfaces.isEmpty()
            || areAllowedInterfacesForLocalBean(interfaces)
            || getEjbInterfaceDeclaringMethod(srcMethod, interfaces) != null) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AbstractTestGenerator.java

示例4: getDefaultProperty

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Attempts to find the {@code @DefaultProperty} annotation on the type, and returns
 * the default property name. Returns null, if @DefaultProperty is not defined
 * 
 * @param te type to inspect
 * @return default property name, or {@code null} if default property is not defined for the type.
 */
public static String getDefaultProperty(TypeElement te) {
    for (AnnotationMirror an : te.getAnnotationMirrors()) {
        if (!((TypeElement)an.getAnnotationType().asElement()).getQualifiedName().contentEquals(DEFAULT_PROPERTY_TYPE_NAME)) {
            continue;
        }
        Map<? extends ExecutableElement, ? extends AnnotationValue> m =  an.getElementValues();
        for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> en : m.entrySet()) {
            if (en.getKey().getSimpleName().contentEquals(DEFAULT_PROPERTY_VALUE_NAME)) {
                Object v = en.getValue().getValue();
                return v == null ? null : v.toString();
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FxClassUtils.java

示例5: isInjectionTarget

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) {
    FileObject fo = controller.getFileObject();
    Project project = FileOwnerQuery.getOwner(fo);
    if (ElementKind.INTERFACE != typeElement.getKind()) {
        List<? extends AnnotationMirror> annotations = typeElement.getAnnotationMirrors();
        boolean found = false;

        for (AnnotationMirror m : annotations) {
            Name qualifiedName = ((TypeElement) m.getAnnotationType().asElement()).getQualifiedName();
            if (qualifiedName.contentEquals("javax.jws.WebService")) {
                //NOI18N
                found = true;
                break;
            }
            if (qualifiedName.contentEquals("javax.jws.WebServiceProvider")) {
                //NOI18N
                found = true;
                break;
            }
        }
        if (found) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaSourceHelper.java

示例6: getClassType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/*************当注解的参数为Class类型时,如果使用的apt技术,直接去获取Class会报异常,因为,此时jvm还没有运行,Class尚未加载*****************/
	public void getClassType(TypeElement type, DUnit dUnit) {
		if (dUnit != null){
//			mErrorReporter.reportWaring("asType:" + type.asType() + "     |getNestingKind:" + type.getNestingKind() + "     |getAnnotation:" + type.getAnnotation(DUnitGroup.class) + "    |getAnnotationMirrors:" + type.getAnnotationMirrors());
			List<? extends AnnotationMirror> mirrors = type.getAnnotationMirrors();
			AnnotationMirror mirror = mirrors.get(0);
			Map<? extends ExecutableElement, ? extends AnnotationValue> map = mirror.getElementValues();
			Set<? extends Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> entries = map.entrySet();
			for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
					entries) {
				ExecutableElement executableElement = entry.getKey();
				mErrorReporter.reportWaring("executableElement" + executableElement);
				AnnotationValue annotationValue = entry.getValue();
				Object object = annotationValue.getValue();
//				boolean isClassType = object instanceof Type.ClassType;
//				if (isClassType){
//					Type.ClassType classType = (Type.ClassType) object;
//					mErrorReporter.reportWaring(classType.toString() + "  |  " + classType.getOriginalType() + "  |  "  + classType.getKind() + "  |  "  + classType.getReturnType()  +  "   |  "  + classType.getUpperBound());
//				}
			}

		}
	}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:24,代码来源:DUnitModelUtil.java

示例7: ClassEntity

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * @param elementUtils
 * @param typeUtils
 * @param element      current anntated class
 */
public ClassEntity(Elements elementUtils, Types typeUtils, TypeElement element) {
    elementWeakCache = new WeakReference<TypeElement>(element);
    this.classPackageName = elementUtils.getPackageOf(element).getQualifiedName().toString();
    this.modifierSet = element.getModifiers();
    this.className = element.toString();
    annotationMirrors = element.getAnnotationMirrors();
    this.classSimpleName = element.getSimpleName();
    this.classQualifiedName = element.getQualifiedName();
    if ("java.lang.Object".equals(element.getSuperclass().toString())){
        this.superclass = null;
    }else{
        this.superclass = element.getSuperclass().toString();
    }
    List<? extends TypeMirror> interfaces = element.getInterfaces();

    for (TypeMirror anInterface : interfaces){
        this.interfaces.add(typeUtils.asElement(anInterface).toString());
    }
}
 
开发者ID:simplezhli,项目名称:RxPay,代码行数:25,代码来源:ClassEntity.java

示例8: getDependFields

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public Set<FieldData> getDependFields(TypeElement te) {
    Set<FieldData> list = new HashSet<>();

    List<? extends AnnotationMirror> mirrors = te.getAnnotationMirrors();
    AnnotationMirror expect = null;
    for(AnnotationMirror am : mirrors){
        DeclaredType type = am.getAnnotationType();
        if(type.toString().equals(Fields.class.getName())){
            expect = am;
            break;
        }
    }
    if(expect != null){
        ElementHelper.parseFields(elements, types, expect, list, pp);
    }
    //a depend b, b depend c ,,, etc.
    List<? extends TypeMirror> superInterfaces = te.getInterfaces();
    for(TypeMirror tm : superInterfaces){
        final TypeElement newTe = (TypeElement) ((DeclaredType) tm).asElement();
        list.addAll(getDependFields(newTe)); //recursion
    }
    return list;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:25,代码来源:MultiModuleSuperFieldDelegate.java

示例9: isLocalOrRemoteInterface

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Checks whether is interface annotated as {@code @javax.ejb.Remote} or {@code @javax.ejb.Local}
 *
 * @param trgInterface interface which should be annotated
 * @return {@code true} if the interface is annotated, {@code false} otherwise
 */
private static boolean isLocalOrRemoteInterface(TypeElement trgInterface) {
    List<? extends AnnotationMirror> annotations = trgInterface.getAnnotationMirrors();
    for (AnnotationMirror am : annotations) {
        String annotation = ((TypeElement)am.getAnnotationType().asElement()).getQualifiedName().toString();
        if (annotation.equals("javax.ejb.Local") ||  // NOI18N
            annotation.equals("javax.ejb.Remote")) { // NOI18N
            // interface is @Local or @Remote
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AbstractTestGenerator.java

示例10: isLocalOrRemoteInterface

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Checks whether is interface annotated as {@literal @javax.ejb.Remote} or {@literal @javax.ejb.Local}
 *
 * @param trgInterface interface which should be annotated
 * @return {@literal true} if the interface is annotated, {@literal false} otherwise
 */
private static boolean isLocalOrRemoteInterface(TypeElement trgInterface) {
    List<? extends AnnotationMirror> annotations = trgInterface.getAnnotationMirrors();
    for (AnnotationMirror am : annotations) {
        String annotation = ((TypeElement)am.getAnnotationType().asElement()).getQualifiedName().toString();
        if (annotation.equals("javax.ejb.Local") ||  // NOI18N
            annotation.equals("javax.ejb.Remote")) { // NOI18N
            // interface is @Local or @Remote
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AbstractTestGenerator.java

示例11: refresh

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean refresh(TypeElement typeElement) {
    AnnotationParser parser = AnnotationParser.create(getHelper());
    parser.expectString("name", AnnotationParser.defaultValue(typeElement.getSimpleName()));
    List<? extends AnnotationMirror> annotations = typeElement.getAnnotationMirrors();
    if (annotations.size() == 0) {
        return false;
    }
    name = parser.parse(annotations.get(0)).get("name", String.class);
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:PersistentObjectManagerTest.java

示例12: getTargetType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
    * Returns the target type of the specified type element representing a parameter converter class.
    * @param converterElement
    * @throws ModelException
    */
String getTargetType(TypeElement converterElement) throws ModelException {
       for (AnnotationMirror am : converterElement.getAnnotationMirrors()) {
           Element ae = typeUtils.asElement(am.getAnnotationType());
           if (ae.equals(converterAnnotation))
               for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> e : am.getElementValues().entrySet())
                   if ("targetType".equals(e.getKey().getSimpleName().toString()))
                       return e.getValue().toString();
       }
       throw new ModelException("cannot read target type for converter: " + converterElement.getQualifiedName());
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:16,代码来源:ModelContext.java

示例13: directContainAnnotation

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * 判断某个元素是否直接包含某注解
 * @param typeElement  类型元素
 * @param qualifiedName 注解的限定名
 */
public boolean directContainAnnotation(TypeElement typeElement,String qualifiedName){
	List<? extends AnnotationMirror> mirrors = typeElement.getAnnotationMirrors();
	if (mirrors.isEmpty()){
		return false;
	}
	String mirrorsString = mirrors.toString();
	return mirrorsString.contains(qualifiedName);
}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:14,代码来源:DUnitModelUtil.java

示例14: getGroupClassType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public void getGroupClassType(TypeElement type, DUnitGroup dUnitGroup) {
		if (dUnitGroup != null) {
			mErrorReporter.reportWaring("asType:" + type.asType() + "     |getNestingKind:" + type.getNestingKind() + "     |getAnnotation:" + type.getAnnotation(DUnitGroup.class) + "    |getAnnotationMirrors:" + type.getAnnotationMirrors());
			mErrorReporter.reportWaring("------------>" + getRealClassName(type));
			List<? extends AnnotationMirror> mirrors = type.getAnnotationMirrors();
			if (mirrors.isEmpty()){
				return;
			}
			AnnotationMirror mirror = mirrors.get(0);
			mErrorReporter.reportWaring("----->mirror:" + mirror);
			Map<? extends ExecutableElement, ? extends AnnotationValue> map = mirror.getElementValues();
			Set<? extends Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> entries = map.entrySet();
			for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
					entries) {
				ExecutableElement executableElement = entry.getKey();
				mErrorReporter.reportWaring("executableElement" + executableElement);
				AnnotationValue annotationValue = entry.getValue();
				Object object = annotationValue.getValue();
//				boolean isClassType = object instanceof Type.ClassType;
//				if (isClassType) {
//					Type.ClassType classType = (Type.ClassType) object;
//					mErrorReporter.reportWaring(classType.toString() + "  |  " + classType.getOriginalType() + "  |  " + classType.getKind() + "  |  " + classType.getReturnType() + "   |  " + classType.getUpperBound());
//				}
			}

		}
	}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:28,代码来源:DUnitModelUtil.java

示例15: isDocumentedAnnotation

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Given an annotation, return true if it should be documented and false
 * otherwise.
 *
 * @param annotation the annotation to check.
 *
 * @return true return true if it should be documented and false otherwise.
 */
public boolean isDocumentedAnnotation(TypeElement annotation) {
    for (AnnotationMirror anno : annotation.getAnnotationMirrors()) {
        if (getFullyQualifiedName(anno.getAnnotationType().asElement()).equals(
                Documented.class.getName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Utils.java


注:本文中的javax.lang.model.element.TypeElement.getAnnotationMirrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。