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


Java ElementKind.ANNOTATION_TYPE屬性代碼示例

本文整理匯總了Java中javax.lang.model.element.ElementKind.ANNOTATION_TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.ANNOTATION_TYPE屬性的具體用法?Java ElementKind.ANNOTATION_TYPE怎麽用?Java ElementKind.ANNOTATION_TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.ANNOTATION_TYPE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: from

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,代碼行數:21,代碼來源:Mirrors.java

示例2: isInaccessibleOutsideOuterClass

/**
 * computes accessibility of members of nested classes
 * @param e member
 * @return {@code true} if the member cannot be accessed outside the outer class
 * @see <a href="http://www.netbeans.org/issues/show_bug.cgi?id=169377">169377</a>
 */
private static boolean isInaccessibleOutsideOuterClass(Element e, ElementUtilities eu) {
    Element enclosing = e.getEnclosingElement();
    boolean isStatic = e.getModifiers().contains(Modifier.STATIC);
    ElementKind kind = e.getKind();
    if (isStatic || kind.isClass() || kind.isInterface() || kind.isField()) {
        // static declaration of nested class, interface, enum, ann type, method, field
        // or inner class
        return isAnyEncloserPrivate(e);
    } else if (enclosing != null && kind == ElementKind.METHOD) {
        // final is enum, ann type and some classes
        ElementKind enclosingKind = enclosing.getKind();
        boolean isEnclosingFinal = enclosing.getModifiers().contains(Modifier.FINAL)
                // ann type is not final even if it cannot be subclassed
                || enclosingKind == ElementKind.ANNOTATION_TYPE;
        return isAnyEncloserPrivate(e) && !eu.overridesMethod((ExecutableElement) e) && !eu.implementsMethod((ExecutableElement)e) &&
                (isEnclosingFinal || !isOverriddenInsideOutermostEnclosingClass((ExecutableElement)e, eu));
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:InstantRenamePerformer.java

示例3: decodeKind

@NonNull
static ElementKind decodeKind (char kind) {
    switch (kind) {
        case EK_CLASS:
        case EK_LOCAL_CLASS:
            return ElementKind.CLASS;
        case EK_INTERFACE:
        case EK_LOCAL_INTERFACE:
            return ElementKind.INTERFACE;
        case EK_ENUM:
        case EK_LOCAL_ENUM:
            return ElementKind.ENUM;
        case EK_ANNOTATION:
        case EK_LOCAL_ANNOTATION:
            return ElementKind.ANNOTATION_TYPE;
        case EK_MODULE:
            return ElementKind.MODULE;
        default:
            throw new IllegalArgumentException ();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:DocumentUtil.java

示例4: javaDocFor

/**Get javadoc for given element.
 * @deprecated The new DocTree API should be used to traverse Javadoc comments.
 * Use {@link DocTrees#getDocCommentTree(javax.lang.model.element.Element)} instead.
 */
@Deprecated
public Doc javaDocFor(Element element) {
    if (element != null) {
        DocEnv env = DocEnv.instance(ctx);
        switch (element.getKind()) {
            case ANNOTATION_TYPE:
            case CLASS:
            case ENUM:
            case INTERFACE:
                return env.getClassDoc((ClassSymbol)element);
            case ENUM_CONSTANT:
            case FIELD:
                return env.getFieldDoc((VarSymbol)element);
            case METHOD:
                if (((MethodSymbol)element).enclClass().getKind() == ElementKind.ANNOTATION_TYPE)
                    return env.getAnnotationTypeElementDoc((MethodSymbol)element);
                return env.getMethodDoc((MethodSymbol)element);
            case CONSTRUCTOR:
                return env.getConstructorDoc((MethodSymbol)element);
            case PACKAGE:
                return env.getPackageDoc((PackageSymbol)element);
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:ElementUtilities.java

示例5: checkAbstractValueType

static boolean checkAbstractValueType(Element element, Collection<String> violations) {
  boolean ofSupportedKind = false
      || element.getKind() == ElementKind.INTERFACE
      || element.getKind() == ElementKind.ANNOTATION_TYPE
      || element.getKind() == ElementKind.CLASS;

  boolean staticOrTopLevel = false
      || element.getEnclosingElement().getKind() == ElementKind.PACKAGE
      || element.getModifiers().contains(Modifier.STATIC);

  boolean nonFinal = !element.getModifiers().contains(Modifier.FINAL);

  boolean publicOrPackageVisible =
      !element.getModifiers().contains(Modifier.PRIVATE)
          && !element.getModifiers().contains(Modifier.PROTECTED);

  if (!ofSupportedKind) {
    violations.add("must be class or interface or annotation type");
  }

  if (!nonFinal) {
    violations.add("must be non-final");
  }

  if (!publicOrPackageVisible) {
    violations.add("should be public or package-visible");
  }

  if (!staticOrTopLevel) {
    violations.add("should be top-level or static inner class");
  }

  return violations.isEmpty();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:ValueTypeComposer.java

示例6: getKind

@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
    long flags = flags();
    if ((flags & ANNOTATION) != 0)
        return ElementKind.ANNOTATION_TYPE;
    else if ((flags & INTERFACE) != 0)
        return ElementKind.INTERFACE;
    else if ((flags & ENUM) != 0)
        return ElementKind.ENUM;
    else
        return ElementKind.CLASS;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:Symbol.java

示例7: typeElementConvertor

@NonNull
public static Convertor<Document,ElementHandle<TypeElement>> typeElementConvertor() {
    return new ElementHandleConvertor<> (
            ElementKind.CLASS,
            ElementKind.ENUM,
            ElementKind.INTERFACE,
            ElementKind.ANNOTATION_TYPE);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:DocumentUtil.java

示例8: getElementKind

private static ElementKind getElementKind(@NonNull final ClassFile cf) {
    if (cf.isEnum()) {
        return ElementKind.ENUM;
    } else if (cf.isAnnotation()) {
        return ElementKind.ANNOTATION_TYPE;
    } else if (cf.isModule()) {
        return ElementKind.MODULE;
    } else if ((cf.getAccess() & Access.INTERFACE) == Access.INTERFACE) {
        return ElementKind.INTERFACE;
    } else {
        return ElementKind.CLASS;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:BinaryAnalyser.java

示例9: doCreateFromTemplate

FileObject doCreateFromTemplate(CompilationUnitTree cut) throws IOException {
    ElementKind kind;
    if ("package-info.java".equals(cut.getSourceFile().getName())) {
        kind = ElementKind.PACKAGE;
    } else if (cut.getTypeDecls().isEmpty()) {
        kind = null;
    } else {
        switch (cut.getTypeDecls().get(0).getKind()) {
            case CLASS:
                kind = ElementKind.CLASS;
                break;
            case INTERFACE:
                kind = ElementKind.INTERFACE;
                break;
            case ANNOTATION_TYPE:
                kind = ElementKind.ANNOTATION_TYPE;
                break;
            case ENUM:
                kind = ElementKind.ENUM;
                break;
            default:
                Logger.getLogger(WorkingCopy.class.getName()).log(Level.SEVERE, "Cannot resolve template for {0}", cut.getTypeDecls().get(0).getKind());
                kind = null;
        }
    }
    FileObject template = FileUtil.getConfigFile(template(kind));
    return doCreateFromTemplate(template, cut.getSourceFile());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:WorkingCopy.java

示例10: getGroupId

/**
 * Returns the group number of the class member. Elements with the same
 * number form a group. Groups with lower numbers should be positioned
 * higher in the class member list.
 * @param element the member element
 * @return the group number
 * @since 0.96
 */
public int getGroupId(Element element) {
    for (Info info : infos) {
        ElementKind kind = element.getKind();
        if (kind == ElementKind.ANNOTATION_TYPE || kind == ElementKind.ENUM || kind == ElementKind.INSTANCE_INIT)
            kind = ElementKind.CLASS;
        if (info.check(kind, element.getModifiers()));
            return info.groupId;
    }
    return infos.length;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CodeStyle.java

示例11: getText

public String getText() {
    if(target.getKind() == ElementKind.ANNOTATION_TYPE)
        return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Annotation_Element", methodDisplayName, inFQN );
    if (returnType != null) {
        return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Method", methodDisplayName, inFQN );
    } else {
        return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Constructor", methodDisplayName, inFQN );
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:CreateMethodFix.java

示例12: isInAnnotationType

static boolean isInAnnotationType(CompilationInfo info, TreePath path) {
    Element e = info.getTrees().getElement(path);
    if (e != null) {
        e = e.getEnclosingElement();
        return e != null && e.getKind() == ElementKind.ANNOTATION_TYPE;
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:TreeUtils.java

示例13: getClassType

private static ElementKind getClassType(Set<ElementKind> types) {
    if (types.contains(ElementKind.CLASS))
        return ElementKind.CLASS;
    if (types.contains(ElementKind.ANNOTATION_TYPE))
        return ElementKind.ANNOTATION_TYPE;
    if (types.contains(ElementKind.INTERFACE))
        return ElementKind.INTERFACE;
    if (types.contains(ElementKind.ENUM))
        return ElementKind.ENUM;

    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:CreateElement.java

示例14: isAnnotationType

public boolean isAnnotationType() {
  return element.getKind() == ElementKind.ANNOTATION_TYPE;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:3,代碼來源:ValueType.java

示例15: isImplementing

public boolean isImplementing() {
  return element.getKind() == ElementKind.INTERFACE
      || element.getKind() == ElementKind.ANNOTATION_TYPE;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:ValueType.java


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