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


Java Name.contentEquals方法代码示例

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


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

示例1: from

import javax.lang.model.element.Name; //导入方法依赖的package包/类
static AttributeTypeKind from(TypeMirror type) {
  if (type.getKind() == TypeKind.DECLARED) {
    TypeElement typeElement = toElement(type);
    if (typeElement.getKind() == ElementKind.ENUM) {
      return ENUM;
    }
    if (typeElement.getKind() == ElementKind.ANNOTATION_TYPE) {
      return ANNOTATION;
    }
    Name qualifiedName = typeElement.getQualifiedName();
    if (qualifiedName.contentEquals(Class.class.getName())) {
      return TYPE;
    }
    if (qualifiedName.contentEquals(String.class.getName())) {
      return STRING;
    }
  } else if (type.getKind().isPrimitive()) {
    return PRIMITIVE;
  }
  throw new AssertionError();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:Mirrors.java

示例2: visitAnnotation

import javax.lang.model.element.Name; //导入方法依赖的package包/类
@Override
public Void visitAnnotation(AnnotationMirror a, Void p) {
  builder.append('@').append(a.getAnnotationType());

  Map<? extends ExecutableElement, ? extends AnnotationValue> values = a.getElementValues();
  if (!values.isEmpty()) {
    builder.append('(');
    boolean notFirst = false;
    for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : values.entrySet()) {
      if (notFirst) {
        builder.append(", ");
      }
      notFirst = true;
      Name name = e.getKey().getSimpleName();
      boolean onlyValue = values.size() == 1 && name.contentEquals(ATTRIBUTE_VALUE);
      if (!onlyValue) {
        builder.append(name).append(" = ");
      }
      printValue(e.getValue());
    }
    builder.append(')');
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:AnnotationMirrors.java

示例3: checkRunWithSuiteAnnotation

import javax.lang.model.element.Name; //导入方法依赖的package包/类
/**
 * Checks that the given annotation is of type
 * <code>{@value #ANN_RUN_WITH}</code> and contains argument
 * <code>{@value #ANN_SUITE}{@literal .class}</code>.
 * 
 * @param  annMirror  annotation to be checked
 * @return  {@code true} if the annotation meets the described criteria,
 *          {@code false} otherwise
 */
private boolean checkRunWithSuiteAnnotation(AnnotationMirror annMirror,
                                            WorkingCopy workingCopy) {
    Map<? extends ExecutableElement,? extends AnnotationValue> annParams
            = annMirror.getElementValues();
    
    if (annParams.size() != 1) {
        return false;
    }
    
    AnnotationValue annValue = annParams.values().iterator().next();
    Name annValueClsName = getAnnotationValueClassName(annValue,
                                                       workingCopy.getTypes());
    return annValueClsName != null
           ? annValueClsName.contentEquals(ANN_SUITE)
           : false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:JUnit4TestGenerator.java

示例4: CascadeTypeImpl

import javax.lang.model.element.Name; //导入方法依赖的package包/类
public CascadeTypeImpl(List<AnnotationValue> cascadeValues) {
    EmptyType tempAll = null, tempPersist = null, tempMerge = null, tempRemove = null, tempRefresh = null;
    for (AnnotationValue value : cascadeValues) {
        Name valueName = ((VariableElement)value.getValue()).getSimpleName();
        if (valueName.contentEquals("ALL")) { // NOI18N
            tempAll = new EmptyTypeImpl();
        } else if (valueName.contentEquals("PERSIST")) { // NOI18N
            tempPersist = new EmptyTypeImpl();
        } else if (valueName.contentEquals("MERGE")) { // NOI18N
            tempMerge = new EmptyTypeImpl();
        } else if (valueName.contentEquals("REMOVE")) { // NOI18N
            tempRemove = new EmptyTypeImpl();
        } else if (valueName.contentEquals("REFRESH")) { // NOI18N
            tempRefresh = new EmptyTypeImpl();
        }
    }
    all = tempAll;
    persist = tempPersist;
    merge = tempMerge;
    remove = tempRemove;
    refresh = tempRefresh;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CascadeTypeImpl.java

示例5: visitNewClass

import javax.lang.model.element.Name; //导入方法依赖的package包/类
@Override
public Boolean visitNewClass(NewClassTree node, Void p) {
    TypeMirror tm = ci.getTrees().getTypeMirror(getCurrentPath());
    if (tm == null || tm.getKind() != TypeKind.DECLARED) {
        return false;
    }
    TypeElement el = (TypeElement)((DeclaredType)tm).asElement();
    if (el == null) {
        return false;
    }
    Name n = el.getQualifiedName();
    boolean res = n.contentEquals("java.lang.StringBuilder") || n.contentEquals("java.lang.StringBuffer"); // NOI18N
    // check if there is some initial contents
    if (node.getArguments().size() == 1 && 
            Utilities.isJavaString(ci, ci.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getArguments().get(0))))) {
        hasContents = true;
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ReplaceBufferByString.java

示例6: isSystemExit

import javax.lang.model.element.Name; //导入方法依赖的package包/类
/**
 * Determines if the element corresponds to never-returning, terminating method.
 * System.exit, Runtime.exit, Runtime.halt are checked. The passed element is
 * usually a result of {@code CompilationInfo.getTrees().getElement(path)}.
 * 
 * @param info context
 * @param e element to check
 * @return true, if the element corrresponds to a VM-exiting method
 */
public static boolean isSystemExit(CompilationInfo info, Element e) {
    if (e == null || e.getKind() != ElementKind.METHOD) {
        return false;
    }
    ExecutableElement ee = (ExecutableElement)e;
    Name n = ee.getSimpleName();
    if (n.contentEquals("exit") || n.contentEquals("halt")) { // NOI18N
        TypeElement tel = info.getElementUtilities().enclosingTypeElement(e);
        if (tel == null) {
            return false;
        }
        Name ofqn = tel.getQualifiedName();
        if (ofqn.contentEquals("java.lang.System") || ofqn.contentEquals("java.lang.Runtime")) { // NOI18N
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:Utilities.java

示例7: isInjectionTarget

import javax.lang.model.element.Name; //导入方法依赖的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

示例8: getInfo

import javax.lang.model.element.Name; //导入方法依赖的package包/类
private PrimitiveData getInfo(String classFQN, AnnotationMirror annotation) {
    String name = null;
    String description = null;
    List<String> tags = Collections.EMPTY_LIST;

    for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation.getElementValues().entrySet()) {
        // name
        Name entryName = entry.getKey().getSimpleName();
        AnnotationValue entryValue = entry.getValue();
        if (entryName.contentEquals("name")) {
            name = getAnnotationValue(String.class, classFQN, "name", entryValue);
        } else if (entryName.contentEquals("description")) {
            description = getAnnotationValue(String.class, classFQN, "description", entryValue);
        } else if (entryName.contentEquals("tags")) {
            List<AnnotationValue> tagList = getAnnotationValue(List.class, classFQN, "tags", entryValue) ;
            if (tagList != null) {
                tags = new ArrayList<String>(tagList.size());
                for (AnnotationValue tagValue : tagList) {
                    String tag = getAnnotationValue(String.class, classFQN, "tags", tagValue);
                    if (tag != null) {
                        tags.add(tag);
                    }
                }
            }
        }
    }
    return new PrimitiveData(classFQN, name, description, tags.toArray(new String[tags.size()]));
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:29,代码来源:ClassCrawler.java

示例9: initSpecialAnnotations

import javax.lang.model.element.Name; //导入方法依赖的package包/类
private void initSpecialAnnotations() {
  for (AnnotationMirror annotation : element.getAnnotationMirrors()) {
    TypeElement annotationElement = (TypeElement) annotation.getAnnotationType().asElement();
    Name simpleName = annotationElement.getSimpleName();
    Name qualifiedName = annotationElement.getQualifiedName();
    if (qualifiedName.contentEquals(Annotations.JAVAX_CHECK_FOR_NULL)
        || qualifiedName.contentEquals(Annotations.JAVAX_NULLABLE)
        || simpleName.contentEquals(containingType.names().nullableAnnotation)) {
      nullability = ImmutableNullabilityAnnotationInfo.of(annotationElement);
    } else if (simpleName.contentEquals(TypeStringProvider.EPHEMERAL_ANNOTATION_ALLOW_NULLS)) {
      nullElements = NullElements.ALLOW;
    } else if (simpleName.contentEquals(TypeStringProvider.EPHEMERAL_ANNOTATION_SKIP_NULLS)) {
      nullElements = NullElements.SKIP;
    }
  }
  if (containingType.isGenerateJacksonProperties()
      && typeKind.isMap()
      && Proto.isAnnotatedWith(element, Annotations.JACKSON_ANY_GETTER)) {
    jacksonAnyGetter = true;
  }
  if (containingType.isGenerateJacksonMapped()
      && (isGenerateAbstract || isGenerateDefault)
      && Proto.isAnnotatedWith(element, Annotations.JACKSON_VALUE)) {
    jacksonValue = true;
  }
  if (isCollectionType()
      && nullElements == NullElements.BAN
      && protoclass().styles().style().validationMethod() == ValidationMethod.NONE) {
    nullElements = NullElements.ALLOW;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:ValueAttribute.java

示例10: getIdx

import javax.lang.model.element.Name; //导入方法依赖的package包/类
private Integer getIdx(Element e, Name n) {
    if (e instanceof ExecutableElement && n != null) {
        int idx = 0;
        for (VariableElement par : ((ExecutableElement)e).getParameters()) {
            if (n.contentEquals(par.getSimpleName())) {
                return idx;
            }
            idx++;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ElementJavadoc.java

示例11: checkSuiteMembersAnnotation

import javax.lang.model.element.Name; //导入方法依赖的package包/类
/**
 * Checks that the given annotation is of type
 * <code>{@value #ANN_SUITE}.{@value #ANN_SUITE_MEMBERS}</code>
 * and contains the given list of classes as (the only) argument,
 * in the same order.
 * 
 * @param  annMirror  annotation to be checked
 * @param  suiteMembers  list of fully qualified class names denoting
 *                       content of the test suite
 * @return  {@code true} if the annotation meets the described criteria,
 *          {@code false} otherwise
 */
private boolean checkSuiteMembersAnnotation(AnnotationMirror annMirror,
                                            List<String> suiteMembers,
                                            WorkingCopy workingCopy) {
    Map<? extends ExecutableElement,? extends AnnotationValue> annParams
            = annMirror.getElementValues();
    
    if (annParams.size() != 1) {
        return false;
    }
    
    AnnotationValue annValue = annParams.values().iterator().next();
    Object value = annValue.getValue();
    if (value instanceof java.util.List) {
        List<? extends AnnotationValue> items
                = (List<? extends AnnotationValue>) value;
        
        if (items.size() != suiteMembers.size()) {
            return false;
        }
        
        Types types = workingCopy.getTypes();
        Iterator<String> suiteMembersIt = suiteMembers.iterator();
        for (AnnotationValue item : items) {
            Name suiteMemberName = getAnnotationValueClassName(item, types);
            if (suiteMemberName == null) {
                return false;
            }
            if (!suiteMemberName.contentEquals(suiteMembersIt.next())) {
                return false;
            }
        }
        return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:TestGenerator.java

示例12: overridesPackagePrivateOutsidePackage

import javax.lang.model.element.Name; //导入方法依赖的package包/类
private boolean overridesPackagePrivateOutsidePackage(ExecutableElement ee, TypeElement impl) {
    Name elemPackageName = getPackageName(ee);
    Name currentPackageName = getPackageName(impl);
    return !ee.getModifiers().contains(Modifier.PRIVATE)
            && !ee.getModifiers().contains(Modifier.PUBLIC)
            && !ee.getModifiers().contains(Modifier.PROTECTED)
            && !currentPackageName.contentEquals(elemPackageName);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ElementUtilities.java

示例13: run

import javax.lang.model.element.Name; //导入方法依赖的package包/类
void run() {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    List<String> opts = Arrays.asList("-parameters");
    JavacTask task = (JavacTask) compiler.getTask(null, null, null, opts, null, null);
    TypeElement t = task.getElements().getTypeElement("T");
    ExecutableElement testMethod = ElementFilter.methodsIn(t.getEnclosedElements()).get(0);
    VariableElement param = testMethod.getParameters().get(0);
    Name paramName = param.getSimpleName();

    if (!paramName.contentEquals("p")) {
        throw new AssertionError("Wrong parameter name: " + paramName);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:T8136453.java

示例14: isUtilityClass

import javax.lang.model.element.Name; //导入方法依赖的package包/类
private static boolean isUtilityClass(CompilationInfo compilationInfo, Element clazz) {
    if (clazz.getKind() != ElementKind.CLASS) {
        return false;
    }
    
    TypeMirror supr = ((TypeElement) clazz).getSuperclass();
    if (supr == null) {
        return false;
    }
    Element superElem = compilationInfo.getTypes().asElement(supr);
    if (superElem instanceof TypeElement) {
        Name superName = compilationInfo.getElements().getBinaryName((TypeElement) superElem);
        if (superName != null && !superName.contentEquals("java.lang.Object")) {
            return false;
        }
    }

    int cnt = 0;
    for (Element m : clazz.getEnclosedElements()) {
        if (m.getKind() == ElementKind.METHOD && isMainMethod(((ExecutableElement) m))) return false;
        if (m.getKind() == ElementKind.METHOD || m.getKind() == ElementKind.FIELD) {
            if (!m.getModifiers().contains(Modifier.STATIC)) return false;
            cnt++;
        }
    }

    return cnt > 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:UtilityClass.java

示例15: createVariables

import javax.lang.model.element.Name; //导入方法依赖的package包/类
/**
 * Crates method formal parameters, following code style conventions.
 * The trees in 'statements' will be rewritten to use the new identifiers.
 * 
 * @param copy working copy
 * @param parameters variables to turn into parameters
 * @param statements trees that should refer to parameters
 * @return 
 */
static List<VariableTree> createVariables(WorkingCopy copy, List<VariableElement> parameters, 
        TreePath targetParent,
        List<TreePath> statements) {
    final TreeMaker make = copy.getTreeMaker();
    List<VariableTree> formalArguments = new LinkedList<VariableTree>();
    CodeStyle cs = CodeStyle.getDefault(copy.getFileObject());
    
    String prefix = cs.getParameterNamePrefix();
    String suffix = cs.getParameterNameSuffix(); 
    Map<VariableElement, CharSequence> renamedVariables = new HashMap<VariableElement, CharSequence>();
    Set<Name> changedNames = new HashSet<Name>();
    for (VariableElement p : parameters) {
        TypeMirror tm = p.asType();
        Tree type = make.Type(tm);
        Name formalArgName = p.getSimpleName();
        Set<Modifier> formalArgMods = EnumSet.noneOf(Modifier.class);
        
        if (p.getModifiers().contains(Modifier.FINAL)) {
            formalArgMods.add(Modifier.FINAL);
        }
        String strippedName = Utilities.stripVariableName(cs, p);
        CharSequence codeStyleName = Utilities.guessName(copy, strippedName, targetParent, prefix, suffix, p.getKind() == ElementKind.PARAMETER);
        if (!formalArgName.contentEquals(codeStyleName)) {
            renamedVariables.put(p, codeStyleName);
            changedNames.add(formalArgName);
        } else {
            codeStyleName = formalArgName;
        }
        formalArguments.add(make.Variable(make.Modifiers(formalArgMods), codeStyleName, type, null));
    }
    if (!changedNames.isEmpty()) {
        VariableRenamer renamer = new VariableRenamer(copy, renamedVariables, changedNames);
        for (TreePath stPath : statements) {
            renamer.scan(stPath, null);
        }
    }
    return formalArguments;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:IntroduceHint.java


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