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


Java TypeElement.equals方法代码示例

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


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

示例1: findDeprecated

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static AnnotationMirror findDeprecated(CompilationInfo javac, Element elm) {
    TypeElement deprAnn = javac.getElements().getTypeElement("java.lang.Deprecated"); //NOI18N
    if (deprAnn == null) {
        String msg = String.format("Even though the source level of %s" + //NOI18N
                " is set to JDK5 or later, java.lang.Deprecated cannot" + //NOI18N
                " be found on the bootclasspath: %s", //NOI18N
                javac.getClasspathInfo().getClassPath(PathKind.SOURCE),
                javac.getClasspathInfo().getClassPath(PathKind.BOOT));
        Logger.getLogger(JavadocUtilities.class.getName()).warning(msg);
        return null;
    }
    for (AnnotationMirror annotationMirror : javac.getElements().getAllAnnotationMirrors(elm)) {
        if (deprAnn.equals(annotationMirror.getAnnotationType().asElement())) {
            return annotationMirror;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavadocUtilities.java

示例2: extend

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/** The super qualifier user to extend this property metadata. */
@Override public @Nullable PropertyReference extend() {
    if (mixinMetamodel != null && mixinProperty != null) {
        return new PropertyReference(mixinMetamodel, mixinProperty);
    }

    // apply bean Qualify(mixin) if this property has no explicit @Extend
    if (isProperty()) {
        Qualify beanQualify = beanElement.getAnnotation(Qualify.class);
        TypeElement classRepresenter = qualifyExtendValue(beanQualify);
        if (classRepresenter != null && !classRepresenter.equals(typeElementFor(Object.class))) {
            return new PropertyReference(
                    ClassName.bestGuess(getQualifierName(getFlatName(classRepresenter))),
                    isNullOrEmpty(mixinProperty) ? name : mixinProperty);
        }
    }

    return null;
}
 
开发者ID:intendia-oss,项目名称:qualifier,代码行数:20,代码来源:StaticQualifierMetamodelProcessor.java

示例3: visitType

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public ImmutableMap.Builder<TypeName,TypeName> visitType(final TypeElement element, final ImmutableMap.Builder<TypeName,TypeName> builder) {

	if (Util.isDeclaredType(element) && !element.equals(objectTypeElement)) {
		if (traverseParentTypes) {
			// Climb the inheritance DAGs for interfaces and classes
			visitIfDeclaredType(element.getSuperclass(), builder);
			element.getInterfaces().stream().forEach(face -> visitIfDeclaredType(face, builder));
		}

		// Capture the current type
		final ClassName type = ClassName.get(element);
		if (!alreadyComputed.contains(type)) { // Ensure that we don't cover old ground
			builder.put(type, computeSubstitution(type));
		}

		// Continue the search for nested types
		element.getEnclosedElements().forEach(child -> visit(child, builder));
	}

	return builder;
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:23,代码来源:Inventory.java

示例4: removeAnnotations

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
static ModifiersTree removeAnnotations(WorkingCopy workingCopy, TreeMaker make,ModifiersTree oldOne, TreePath path) {
    TypeElement override = workingCopy.getElements().getTypeElement("java.lang.Override");
    if(override == null) {
        return oldOne;
    }
    List<AnnotationTree> newAnnotations = new LinkedList<>();
    for (AnnotationTree annotationTree : oldOne.getAnnotations()) {
        Element el = workingCopy.getTrees().getElement(new TreePath(path, annotationTree));
        if(!override.equals(el)) {
            newAnnotations.add(annotationTree);
        }
    }
    return make.Modifiers(oldOne, newAnnotations);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PullUpTransformer.java

示例5: getAccessModifiers

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static Visibility getAccessModifiers(@NonNull CompilationInfo info, @NullAllowed TypeElement source, @NonNull TypeElement target) {
    if (target.getKind().isInterface()) {
        return Visibility.PUBLIC;
    }

    TypeElement outterMostSource = source != null ? info.getElementUtilities().outermostTypeElement(source) : null;
    TypeElement outterMostTarget = info.getElementUtilities().outermostTypeElement(target);

    if (outterMostTarget.equals(outterMostSource)) {
        return Visibility.PRIVATE;
    }

    Element sourcePackage;

    if (outterMostSource != null) {
        sourcePackage = outterMostSource.getEnclosingElement();
    } else if (info.getCompilationUnit().getPackageName() != null) {
        sourcePackage = info.getTrees().getElement(new TreePath(new TreePath(info.getCompilationUnit()), info.getCompilationUnit().getPackageName()));
    } else {
        sourcePackage = info.getElements().getPackageElement("");
    }

    Element targetPackage = outterMostTarget.getEnclosingElement();

    if (sourcePackage != null && sourcePackage.equals(targetPackage)) {
        return Visibility.PACKAGE_PRIVATE;
    }

    //TODO: protected?
    return Visibility.PUBLIC;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Utilities.java

示例6: preProcessWebService

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
protected void preProcessWebService(WebService webService, TypeElement element) {
    processedMethods = new HashSet<String>();
    seiContext = context.getSeiContext(element);
    String targetNamespace = null;
    if (webService != null)
        targetNamespace = webService.targetNamespace();
    PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element);
    if (targetNamespace == null || targetNamespace.length() == 0) {
        String packageName = packageElement.getQualifiedName().toString();
        if (packageName == null || packageName.length() == 0) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE(
                    element.getQualifiedName()), element);
        }
        targetNamespace = RuntimeModeler.getNamespace(packageName);
    }
    seiContext.setNamespaceUri(targetNamespace);
    if (serviceImplName == null)
        serviceImplName = seiContext.getSeiImplName();
    if (serviceImplName != null) {
        seiContext.setSeiImplName(serviceImplName);
        context.addSeiContext(serviceImplName, seiContext);
    }
    portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_'));
    packageName = packageElement.getQualifiedName();
    portName = webService != null && webService.name() != null && webService.name().length() > 0 ?
            webService.name() : portName;
    serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue();
    serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ?
            webService.serviceName() : serviceName;
    wsdlNamespace = seiContext.getNamespaceUri();
    typeNamespace = wsdlNamespace;

    SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        pushedSoapBinding = pushSoapBinding(soapBinding, element, element);
    } else if (element.equals(typeElement)) {
        pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:WebServiceVisitor.java

示例7: processAnnotated

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private void processAnnotated(Element element) {
    Qualify.Extend extend = element.getAnnotation(Qualify.Extend.class);
    if (extend != null) {
        if (mixinMetamodel != null) print(Kind.ERROR, "multiple mixin definitions", element);
        TypeElement mixin = qualifyExtendValue(extend);
        if (!mixin.equals(typeElementFor(Object.class))) {
            mixinMetamodel = ClassName.bestGuess(getQualifierName(getFlatName(mixin)));
        }
        mixinProperty = extend.name().isEmpty() ? name : extend.name();
    }
    getProviders().forEach(extension -> extension.processAnnotated(element, metadata()));
}
 
开发者ID:intendia-oss,项目名称:qualifier,代码行数:13,代码来源:StaticQualifierMetamodelProcessor.java

示例8: findAnnotationMirror

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, List<? extends AnnotationMirror> mirrors, Class<?> annotationClass) {
    TypeElement expectedAnnotationType = processingEnv.getElementUtils().getTypeElement(annotationClass.getCanonicalName());
    for (AnnotationMirror mirror : mirrors) {
        DeclaredType annotationType = mirror.getAnnotationType();
        TypeElement actualAnnotationType = (TypeElement) annotationType.asElement();
        if (actualAnnotationType.equals(expectedAnnotationType)) {
            return mirror;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:VerifierAnnotationProcessor.java

示例9: addComments

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
    TypeElement holder = utils.asTypeElement(holderType);
    if (!utils.getFullBody(method).isEmpty()) {
        if (holder.equals(typeElement) ||
                !(utils.isPublic(holder) ||
                utils.isLinkable(holder))) {
            writer.addInlineComment(method, methodDocTree);
        } else {
            Content link =
                    writer.getDocLink(LinkInfoImpl.Kind.EXECUTABLE_ELEMENT_COPY,
                    holder, method,
                    utils.isIncluded(holder)
                            ? utils.getSimpleName(holder)
                            : utils.getFullyQualifiedName(holder),
                        false);
            Content codelLink = HtmlTree.CODE(link);
            Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
                    utils.isClass(holder)
                            ? contents.descfrmClassLabel
                            : contents.descfrmInterfaceLabel);
            descfrmLabel.addContent(Contents.SPACE);
            descfrmLabel.addContent(codelLink);
            methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
            writer.addInlineComment(method, methodDocTree);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:MethodWriterImpl.java

示例10: addComments

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addComments(ExecutableElement property, Content propertyDocTree) {
    TypeElement holder = (TypeElement)property.getEnclosingElement();
    if (!utils.getFullBody(property).isEmpty()) {
        if (holder.equals(typeElement) ||
                (!utils.isPublic(holder) || utils.isLinkable(holder))) {
            writer.addInlineComment(property, propertyDocTree);
        } else {
            Content link =
                    writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_COPY,
                    holder, property,
                    utils.isIncluded(holder)
                            ? holder.getSimpleName() : holder.getQualifiedName(),
                        false);
            Content codeLink = HtmlTree.CODE(link);
            Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
                    utils.isClass(holder)
                            ? contents.descfrmClassLabel
                            : contents.descfrmInterfaceLabel);
            descfrmLabel.addContent(Contents.SPACE);
            descfrmLabel.addContent(codeLink);
            propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
            writer.addInlineComment(property, propertyDocTree);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:PropertyWriterImpl.java

示例11: processUtilityCandidateMethod

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
private void processUtilityCandidateMethod(ExecutableElement utilityMethodCandidate, TypeElement originalType) {
  Name name = utilityMethodCandidate.getSimpleName();
  List<? extends VariableElement> parameters = utilityMethodCandidate.getParameters();

  TypeElement definingType = (TypeElement) utilityMethodCandidate.getEnclosingElement();
  boolean nonFinal = !utilityMethodCandidate.getModifiers().contains(Modifier.FINAL);
  boolean nonAbstract = !utilityMethodCandidate.getModifiers().contains(Modifier.ABSTRACT);

  if (definingType.getQualifiedName().contentEquals(Object.class.getName())) {
    // We ignore methods of java.lang.Object
    return;
  }

  if (name.contentEquals(EQUALS_METHOD)
      && parameters.size() == 1
      && parameters.get(0).asType().toString().equals(Object.class.getName())) {

    if (nonAbstract) {
      type.isEqualToDefined = true;

      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits overriden 'equals' method but have some non-inherited attributes."
                + " Please override 'equals' with abstract method to have it generate. Otherwise override"
                + " with calling super implemtation to use custom implementation");
      }
    }
    return;
  }

  if (name.contentEquals(HASH_CODE_METHOD)
      && parameters.isEmpty()) {
    if (nonAbstract) {
      type.isHashCodeDefined = true;

      // inherited non-abstract implementation
      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits non-default 'hashCode' method but have some non-inherited attributes."
                + " Please override 'hashCode' with abstract method to have it generated. Otherwise override"
                + " with calling super implemtation to use custom implementation");
      }
    }
    return;
  }

  if (name.contentEquals(TO_STRING_METHOD)
      && parameters.isEmpty()) {
    if (nonAbstract) {
      type.isToStringDefined = true;

      // inherited non-abstract implementation
      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits non-default 'toString' method but have some non-inherited attributes."
                + " Please override 'toString' with abstract method to have generate it. Otherwise override"
                + " with calling super implementation to use custom implementation");
      }
    }
    return;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:63,代码来源:AccessorAttributesCollector.java

示例12: getCompletions

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element annotated, AnnotationMirror annotation, ExecutableElement attr, String userText) {
    if (processingEnv == null || annotated == null || !annotated.getKind().isClass()) {
        return Collections.emptyList();
    }

    if (   annotation == null
        || !"org.netbeans.api.editor.mimelookup.MimeRegistration".contentEquals(((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName())) {
        return Collections.emptyList();
    }

    if ("mimeType".contentEquals(attr.getSimpleName())) { // NOI18N
        return completeMimePath(annotated, annotation, attr, userText);
    }
    if (!"service".contentEquals(attr.getSimpleName())) {
        return Collections.emptyList();
    }

    TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");

    if (jlObject == null) {
        return Collections.emptyList();
    }

    Collection<Completion> result = new LinkedList<Completion>();
    List<TypeElement> toProcess = new LinkedList<TypeElement>();

    toProcess.add((TypeElement) annotated);

    while (!toProcess.isEmpty()) {
        TypeElement c = toProcess.remove(0);

        result.add(new TypeCompletion(c.getQualifiedName().toString() + ".class"));

        List<TypeMirror> parents = new LinkedList<TypeMirror>();

        parents.add(c.getSuperclass());
        parents.addAll(c.getInterfaces());

        for (TypeMirror tm : parents) {
            if (tm == null || tm.getKind() != TypeKind.DECLARED) {
                continue;
            }

            TypeElement type = (TypeElement) processingEnv.getTypeUtils().asElement(tm);

            if (!jlObject.equals(type)) {
                toProcess.add(type);
            }
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:CreateRegistrationProcessor.java

示例13: getCompletions

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public Iterable<? extends Completion> getCompletions(Element annotated, AnnotationMirror annotation, ExecutableElement attr, String userText) {
    if (processingEnv == null || annotated == null || !annotated.getKind().isClass()) {
        return Collections.emptyList();
    }

    if (   annotation == null
        || !"org.openide.util.lookup.ServiceProvider".contentEquals(((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName())) {
        return Collections.emptyList();
    }

    if (!"service".contentEquals(attr.getSimpleName())) {
        return Collections.emptyList();
    }

    TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");

    if (jlObject == null) {
        return Collections.emptyList();
    }
    
    Collection<Completion> result = new LinkedList<Completion>();
    List<TypeElement> toProcess = new LinkedList<TypeElement>();

    toProcess.add((TypeElement) annotated);

    while (!toProcess.isEmpty()) {
        TypeElement c = toProcess.remove(0);

        result.add(new TypeCompletion(c.getQualifiedName().toString() + ".class"));

        List<TypeMirror> parents = new LinkedList<TypeMirror>();

        parents.add(c.getSuperclass());
        parents.addAll(c.getInterfaces());

        for (TypeMirror tm : parents) {
            if (tm == null || tm.getKind() != TypeKind.DECLARED) {
                continue;
            }

            TypeElement type = (TypeElement) processingEnv.getTypeUtils().asElement(tm);

            if (!jlObject.equals(type)) {
                toProcess.add(type);
            }
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:ServiceProviderProcessor.java

示例14: isSubclass

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
public static boolean isSubclass(TypeElement subType, TypeElement superType, ProcessingEnvironment env) {
    return !subType.equals(superType) && isSubElement(subType, superType);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:TypeModeler.java

示例15: process

import javax.lang.model.element.TypeElement; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver()) {
        return false;
    }

    GraphNodeVerifier verifier = new GraphNodeVerifier(this);

    for (Element element : roundEnv.getElementsAnnotatedWith(NodeInfo.class)) {
        scope = element;
        try {
            if (!isNodeType(element)) {
                errorMessage(element, "%s can only be applied to Node subclasses", NodeInfo.class.getSimpleName());
                continue;
            }

            NodeInfo nodeInfo = element.getAnnotation(NodeInfo.class);
            if (nodeInfo == null) {
                errorMessage(element, "Cannot get %s annotation from annotated element", NodeInfo.class.getSimpleName());
                continue;
            }

            TypeElement typeElement = (TypeElement) element;

            Set<Modifier> modifiers = typeElement.getModifiers();
            if (!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)) {
                // TODO(thomaswue): Reenable this check.
                // errorMessage(element, "%s annotated class must be either final or abstract",
                // NodeInfo.class.getSimpleName());
                // continue;
            }
            boolean found = false;
            for (Element e : typeElement.getEnclosedElements()) {
                if (e.getKind() == ElementKind.FIELD) {
                    if (e.getSimpleName().toString().equals("TYPE")) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                errorMessage(element, "%s annotated class must have a field named TYPE", NodeInfo.class.getSimpleName());
            }

            if (!typeElement.equals(verifier.Node) && !modifiers.contains(Modifier.ABSTRACT)) {
                verifier.verify(typeElement);
            }
        } catch (ElementException ee) {
            errorMessage(ee.element, ee.getMessage());
        } catch (Throwable t) {
            reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t);
        } finally {
            scope = null;
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:58,代码来源:GraphNodeProcessor.java


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