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


Java TypeElement.getInterfaces方法代码示例

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


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

示例1: addMethodInfo

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Add method information.
 *
 * @param method the method to be documented
 * @param dl the content tree to which the method information will be added
 */
private void addMethodInfo(ExecutableElement method, Content dl) {
    TypeElement enclosing = utils.getEnclosingTypeElement(method);
    List<? extends TypeMirror> intfacs = enclosing.getInterfaces();
    ExecutableElement overriddenMethod = utils.overriddenMethod(method);
    // Check whether there is any implementation or overridden info to be
    // printed. If no overridden or implementation info needs to be
    // printed, do not print this section.
    if ((!intfacs.isEmpty()
            && new ImplementedMethods(method, this.configuration).build().isEmpty() == false)
            || overriddenMethod != null) {
        MethodWriterImpl.addImplementsInfo(this, method, dl);
        if (overriddenMethod != null) {
            MethodWriterImpl.addOverridden(this,
                    utils.overriddenType(method),
                    overriddenMethod,
                    dl);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:HtmlDocletWriter.java

示例2: processInterface

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * For the interface passed get the interfaces which it extends, and then
 * put this interface in the sub-interface set of those interfaces. Do it
 * recursively. If a interface doesn't have super-interface just attach
 * that interface in the set of all the baseInterfaces.
 *
 * @param typeElement Interface under consideration.
 */
private void processInterface(TypeElement typeElement) {
    List<? extends TypeMirror> intfacs = typeElement.getInterfaces();
    if (!intfacs.isEmpty()) {
        for (TypeMirror intfac : intfacs) {
            if (!add(subInterfaces, utils.asTypeElement(intfac), typeElement)) {
                return;
            } else {
                processInterface(utils.asTypeElement(intfac));   // Recurse
            }
        }
    } else {
        // we need to add all the interfaces who do not have
        // super-interfaces to baseInterfaces set to traverse them
        if (!baseInterfaces.contains(typeElement)) {
            baseInterfaces.add(typeElement);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ClassTree.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
 * {@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

示例4: 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

示例5: getSuperInterfaceFlagForParent

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * get the super interface flags for parent
 * @param te the current type element
 * @param pp the log printer
 * @return the flags.
 */
public static int getSuperInterfaceFlagForParent(TypeElement te,
                                                 Elements mElements, Types types, ProcessorPrinter pp){
    final String tag = te.getSimpleName().toString();
    List<? extends TypeMirror> interfaces = te.getInterfaces();
    for(TypeMirror tm: interfaces) {
        // pp.note(TAG, "getSuperInteraceFlagForParent_" + tag, "TypeMirror : " + tm);
        FieldData.TypeCompat tc = new FieldData.TypeCompat(types, tm);
        tc.replaceIfNeed(mElements, pp);
        pp.note(TAG, "getSuperInteraceFlagForParent_" + tag, "TypeMirror : " + tm
                + " , hasAnnotationFields = " + tc.hasAnnotationFields());
        if(tc.hasAnnotationFields()){
            //we want.
            int sum = 0;
            final Set<Integer> flags = getSuperInterfaceFlags(tag,
                    tc.getElementAsType(), types, pp);
            for(Integer val : flags){
                sum += val;
            }
            return sum;
        }
    }
    return 0;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:30,代码来源:OutInterfaceManager.java

示例6: 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

示例7: getDeclaringClassMethod

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static TypeElement getDeclaringClassMethod(TypeElement theClass, String methodName, TypeMirror[] args) {

        TypeElement retClass = null;
        if (theClass.getKind().equals(ElementKind.CLASS)) {
            TypeMirror superClass = theClass.getSuperclass();
            if (!superClass.getKind().equals(TypeKind.NONE))
                retClass = getDeclaringClassMethod(superClass, methodName, args);
        }
        if (retClass == null) {
            for (TypeMirror interfaceType : theClass.getInterfaces()) {
                retClass = getDeclaringClassMethod(interfaceType, methodName, args);
            }
        }
        if (retClass == null) {
            Collection<? extends ExecutableElement> methods = ElementFilter.methodsIn(theClass.getEnclosedElements());
            for (ExecutableElement method : methods) {
                if (method.getSimpleName().toString().equals(methodName)) {
                    retClass = theClass;
                    break;
                }
            }
        }
        return retClass;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:TypeModeler.java

示例8: getAttentionInterfaces

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * get the focus/attention interface ,like Parcelable, IReset and etc..
 * @param te the type element of current visit
 *           which is annotated by {@literal @}{@linkplain com.heaven7.java.data.mediator.Fields}.
 * @param types the type util
 * @return the all interfaces proxy need.
 */
private static List<? extends TypeMirror> getAttentionInterfaces(TypeElement te, Types types,
                                                                 List<String> existInterfaces, ProcessorPrinter pp) {

    pp.note(TAG, "getAttentionInterfaces", "start >>> te : " + te);
    final List<TypeMirror> list = new ArrayList<>();

    List<? extends TypeMirror> interfaces = te.getInterfaces();
    for(TypeMirror tm: interfaces){
        pp.note(TAG, "getAttentionInterfaces", "TypeMirror : " + tm);
        FieldData.TypeCompat tc = new FieldData.TypeCompat(types, tm);
        TypeElement newTe = tc.getElementAsType();
        String interfaceName = newTe.getQualifiedName().toString();
        if(sFillerMap.get(interfaceName) != null){
            if(!existInterfaces.contains(interfaceName)) {
                list.add(tm);
                existInterfaces.add(interfaceName);
            }
        }else{
            list.addAll(getAttentionInterfaces(newTe, types, existInterfaces, pp));
        }
    }
    pp.note(TAG, "getAttentionInterfaces", "end >>> te : " + te);
    return list;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:32,代码来源:OutInterfaceManager.java

示例9: classImplementsSei

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
protected boolean classImplementsSei(TypeElement classElement, TypeElement interfaceElement) {
    for (TypeMirror interfaceType : classElement.getInterfaces()) {
        if (((DeclaredType) interfaceType).asElement().equals(interfaceElement))
            return true;
    }
    List<ExecutableElement> classMethods = getClassMethods(classElement);
    boolean implementsMethod;
    for (ExecutableElement interfaceMethod : ElementFilter.methodsIn(interfaceElement.getEnclosedElements())) {
        implementsMethod = false;
        for (ExecutableElement classMethod : classMethods) {
            if (sameMethod(interfaceMethod, classMethod)) {
                implementsMethod = true;
                classMethods.remove(classMethod);
                break;
            }
        }
        if (!implementsMethod) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_NOT_IMPLEMENTED(interfaceElement.getSimpleName(), classElement.getSimpleName(), interfaceMethod), interfaceMethod);
            return false;
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:WebServiceVisitor.java

示例10: searchInterfacesAncestry

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean searchInterfacesAncestry(TypeMirror rootIface, TypeMirror target) {
  TypeElement rootIfaceElement = (TypeElement) typeUtils.asElement(rootIface);
  // check if it implements valid interfaces
  for (TypeMirror iface : rootIfaceElement.getInterfaces()) {
    TypeElement ifaceElement = (TypeElement) typeUtils.asElement(rootIface);
    while (iface.getKind() != TypeKind.NONE) {
      if (typeUtils.isSameType(iface, target)) {
        return true;
      }
      // go up
      if (searchInterfacesAncestry(iface, target)) {
        return true;
      }
      // then move on
      iface = ifaceElement.getSuperclass();
    }
  }
  return false;
}
 
开发者ID:hzsweers,项目名称:inspector,代码行数:20,代码来源:InspectorFactoryProcessor.java

示例11: superProperties

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * Returns a list of all of the super properties of this element in order starting from the most super type.
 * @param env the environment, must not be null
 * @return the properties, must not be null
 */
public List<ImmuProperty> superProperties(ProcessingEnvironment env) {
  final TypeElement typeElement = (TypeElement) element;

  final List<? extends TypeMirror> interfaces = typeElement.getInterfaces();

  final List<ImmuProperty> properties = new LinkedList<>();

  for (TypeMirror typeMirror : interfaces) {
    properties.addAll(superProperties(env, typeMirror));
  }

  return properties;
}
 
开发者ID:hf,项目名称:immu,代码行数:19,代码来源:ImmuObjectElement.java

示例12: iterateInterfaces

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private List<Method> iterateInterfaces(int level, TypeElement parentElement, String parentDefaultStrategy, Map<String, String> parentTypes, List<Method> rootMethods, List<Method> superinterfacesMethods) {
	for (TypeMirror typeMirror : parentElement.getInterfaces()) {
		final TypeElement anInterface = (TypeElement) ((DeclaredType) typeMirror).asElement();

		final List<? extends TypeMirror> typeArguments = ((DeclaredType) typeMirror).getTypeArguments();
		final List<? extends TypeParameterElement> typeParameters = anInterface.getTypeParameters();

		if (typeArguments.size() > typeParameters.size()) {
			throw new IllegalArgumentException("Code generation for interface " + anInterface.getSimpleName() + " failed. Simplify your generics.");
		}

		Map<String, String> types = new HashMap<>();
		for (int i = 0; i < typeArguments.size(); i++) {
			types.put(typeParameters.get(i).toString(), typeArguments.get(i).toString());
		}

		Map<String, String> totalInterfaceTypes = new HashMap<>(typeParameters.size());
		for (int i = 0; i < typeArguments.size(); i++) {
			totalInterfaceTypes.put(typeParameters.get(i).toString(), fillGenerics(parentTypes, typeArguments.get(i)));
		}
		for (int i = typeArguments.size(); i < typeParameters.size(); i++) {
			if (typeParameters.get(i).getBounds().size() != 1) {
				throw new IllegalArgumentException("Code generation for interface " + anInterface.getSimpleName() + " failed. Simplify your generics.");
			}

			totalInterfaceTypes.put(typeParameters.get(i).toString(), typeParameters.get(i).getBounds().get(0).toString());
		}

		String defaultStrategy = parentDefaultStrategy != null ? parentDefaultStrategy : getStateStrategyType(anInterface);

		getMethods(totalInterfaceTypes, anInterface, defaultStrategy, rootMethods, superinterfacesMethods);

		iterateInterfaces(level + 1, anInterface, defaultStrategy, types, rootMethods, superinterfacesMethods);
	}

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

示例13: isRemote

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static boolean isRemote(/*@NotNull*/ TypeElement typeElement) {
    for (TypeMirror superType : typeElement.getInterfaces()) {
        TypeElement name = (TypeElement) ((DeclaredType) superType).asElement();
        if (name.getQualifiedName().contentEquals(REMOTE)) {
            return true;
        }
        isRemote(name);
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TypeModeler.java

示例14: isSubtypeOfType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private boolean isSubtypeOfType(TypeMirror typeMirror, String otherType) {
    if (otherType.equals(typeMirror.toString())) {
        return true;
    }
    if (!(typeMirror instanceof DeclaredType)) {
        return false;
    }
    DeclaredType declaredType = (DeclaredType) typeMirror;
    List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
    if (typeArguments.size() > 0) {
        StringBuilder typeString = new StringBuilder(declaredType.asElement().toString());
        typeString.append('<');
        for (int i = 0; i < typeArguments.size(); i++) {
            if (i > 0) {
                typeString.append(',');
            }
            typeString.append('?');
        }
        typeString.append('>');
        if (typeString.toString().equals(otherType)) {
            return true;
        }
    }
    Element element = declaredType.asElement();
    if (!(element instanceof TypeElement)) {
        return false;
    }
    TypeElement typeElement = (TypeElement) element;
    if (isSubtypeOfType(typeElement.getSuperclass(), otherType)) {
        return true;
    }
    for (TypeMirror interfaceType : typeElement.getInterfaces()) {
        if (isSubtypeOfType(interfaceType, otherType)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:39,代码来源:ButterKnifeProcessor.java

示例15: verifySelfContainedAPI

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private void verifySelfContainedAPI(TypeElement tel) {
    if (!shouldCheck(tel.getModifiers()))
        return; //do not check non-public things
    
    verifyAPIClass(tel.getSuperclass(), tel);
    
    for (TypeMirror intf : tel.getInterfaces()) {
        verifyAPIClass(intf, tel);
    }
    
    for (Element e : tel.getEnclosedElements()) {
        verifySelfContainedAPI(e, tel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:APIIsSelfContainedTest.java


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