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


Java ElementKind.INTERFACE屬性代碼示例

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


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

示例1: createClass

@NonNull
protected TypeSpec.Builder createClass(@NonNull final FieldSpec... members) {
    final TypeSpec.Builder builder = TypeSpec.classBuilder("Proxy_" + type.flatClassName)
            .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT);

    // TODO: mimic annotations of the super type

    if (ElementKind.INTERFACE == type.element.getKind()) {
        builder.addSuperinterface(superType);
    } else if (ElementKind.CLASS == type.element.getKind()) {
        builder.superclass(superType);
    } else {
        final String message = "Unsupported data type: " + type.element.getKind() + ", " + type.elementType;
        errors.write(message + "\n");

        throw new UnsupportedOperationException(message);
    }

    for (final FieldSpec member : members) {
        builder.addField(member);
    }

    return builder;
}
 
開發者ID:OleksandrKucherenko,項目名稱:autoproxy,代碼行數:24,代碼來源:CommonClassGenerator.java

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

示例3: parse

public static Spec parse(Element element, ProcessingEnvironment processingEnv) {
  Messager messager = processingEnv.getMessager();

  if (element.getKind() != ElementKind.INTERFACE) {
    messager.printMessage(
        Diagnostic.Kind.ERROR, "@DataEnum can only be used on interfaces.", element);
    return null;
  }

  TypeElement dataEnum = (TypeElement) element;

  List<TypeVariableName> typeVariableNames = new ArrayList<>();
  for (TypeParameterElement typeParameterElement : dataEnum.getTypeParameters()) {
    typeVariableNames.add(TypeVariableName.get(typeParameterElement));
  }

  List<Value> values = ValuesParser.parse(dataEnum, processingEnv);
  if (values == null) {
    return null;
  }

  ClassName enumInterface = ClassName.get(dataEnum);
  return new Spec(enumInterface, typeVariableNames, values);
}
 
開發者ID:spotify,項目名稱:dataenum,代碼行數:24,代碼來源:SpecParser.java

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

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

示例6: process

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
    for (Element element : env.getElementsAnnotatedWith(Remoter.class)) {
        if (element.getKind() == ElementKind.INTERFACE) {
            bindingManager.generateProxy(element);
            bindingManager.generateStub(element);
        } else {
            messager.printMessage(Diagnostic.Kind.WARNING, "@Remoter is expected only for interface. Ignoring " + element.getSimpleName());
        }
    }
    return false;
}
 
開發者ID:josesamuel,項目名稱:remoter,代碼行數:12,代碼來源:RemoterProcessor.java

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

示例8: createObjects

@Override
public List<T> createObjects(TypeElement type) {
    final List<T> result = new ArrayList<T>();
    if (type.getKind() == ElementKind.CLASS || type.getKind() == ElementKind.INTERFACE) {
        if (helper.hasAnyAnnotation(type.getAnnotationMirrors(), getAnnotationTypeNames())) {
            result.add(createObject(helper, type));
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ObjectProviders.java

示例9: visitLambdaExpression

@Override
public Tree visitLambdaExpression(LambdaExpressionTree node, Element elementToFind) {
    Element type = elementToFind.getEnclosingElement();
    if (type.getKind() == ElementKind.INTERFACE &&
            workingCopy.getElements().isFunctionalInterface((TypeElement) type) &&
            !workingCopy.getTreeUtilities().isSynthetic(getCurrentPath())) {
        
        TypeMirror typeMirror = workingCopy.getTrees().getTypeMirror(getCurrentPath());
        
        if (typeMirror != null && workingCopy.getTypes().isSameType(typeMirror, type.asType())) {
            addUsage(getCurrentPath());
        }
    }
    return super.visitLambdaExpression(node, elementToFind);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:FindOverridingVisitor.java

示例10: process

@Override
public void process( TypeElement typeElement, TypeProcessor typeProcessor, IssueReporter<JavaFileObject> issueReporter )
{
  if( typeElement.getKind() == ElementKind.CLASS || typeElement.getKind() == ElementKind.INTERFACE )
  {
    TreeTranslator visitor = new ExtensionTransformer( this, typeProcessor );
    typeProcessor.getTree().accept( visitor );
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:9,代碼來源:ExtensionManifold.java

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

示例12: findOwnerType

protected TypeElement findOwnerType(Element el) {
    Element t;
    if (el instanceof TypeElement) {
        t = ((TypeElement)el);
    } else {
        t = ci.getElementUtilities().enclosingTypeElement(el);
        if (t == null) {
            return null;
        }
    }
    ElementKind k = t.getKind();
    TypeMirror declType = ci.getTypes().erasure(t.asType());
    
    for (TypeElement enclType = enclosingType; enclType != null; enclType = ci.getElementUtilities().enclosingTypeElement(enclType)) {
        if (ci.getTypes().isSubtype(ci.getTypes().erasure(enclType.asType()), declType)) {
            if (k.isClass()) {
                return enclType;
            } else if (k == ElementKind.INTERFACE) {
                if (t.getModifiers().contains(Modifier.DEFAULT)) {
                    return enclType;
                }
            }
            break;
        }
    }
    // PENDING - this is strange, report an error ??
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:InstanceRefFinder.java

示例13: check

@TriggerTreeKind({Tree.Kind.CLASS, Tree.Kind.INTERFACE})
public static ErrorDescription check(HintContext context) {
    TreePath tp = context.getPath();
    ClassTree cls = (ClassTree) tp.getLeaf();
    CompilationInfo info = context.getInfo();
    SourcePositions sourcePositions = info.getTrees().getSourcePositions();
    long startPos = sourcePositions.getStartPosition(tp.getCompilationUnit(), cls);
    if (startPos > Integer.MAX_VALUE) {
        return null;
    }
    int[] bodySpan = info.getTreeUtilities().findBodySpan(cls);
    if (bodySpan == null || bodySpan[0] <= startPos) {
        return null;
    }
    int caret = context.getCaretLocation();
    if (startPos < 0 || caret < 0 || caret < startPos || caret >= bodySpan[0]) {
        return null;
    }

    // #222487
    // If there is a compile-time error on the class, then don't offer to
    // create a subclass.
    List<Diagnostic> errors = info.getDiagnostics();
    if (!errors.isEmpty()) {
        for (Diagnostic d : errors) {
            if (d.getKind() != Diagnostic.Kind.ERROR) {
                continue;
            }
            // Check that the error's start position is within the class header
            // Note: d.getEndPosition() is not used because, for example,
            // a "compiler.err.does.not.override.abstract" error ends at
            // the end of the class tree.
            if (startPos <= d.getStartPosition() && d.getStartPosition() <= bodySpan[0]) {
                return null;
            }
        }
    }

    TypeElement typeElement = (TypeElement) info.getTrees().getElement(tp);
    
    if (typeElement == null || typeElement.getModifiers().contains(Modifier.FINAL)) return null;

    Element outer = typeElement.getEnclosingElement();
    // do not offer the hint for non-static inner classes. Permit for classes nested into itnerface - no enclosing instance
    if (outer != null && outer.getKind() != ElementKind.PACKAGE && outer.getKind() != ElementKind.INTERFACE) {
        if (outer.getKind() != ElementKind.CLASS && outer.getKind() != ElementKind.ENUM) {
            return null;
        }
        if (!typeElement.getModifiers().contains(Modifier.STATIC)) {
            return null;
        }
    }

    
    ClassPath cp = info.getClasspathInfo().getClassPath(PathKind.SOURCE);
    FileObject root = cp.findOwnerRoot(info.getFileObject());
    if (root == null) { //File not part of any project
        return null;
    }

    PackageElement packageElement = (PackageElement) info.getElementUtilities().outermostTypeElement(typeElement).getEnclosingElement();
    CreateSubclassFix fix = new CreateSubclassFix(info, root, packageElement.getQualifiedName().toString(), typeElement.getSimpleName().toString() + "Impl", typeElement); //NOI18N
    return ErrorDescriptionFactory.forTree(context, context.getPath(), NbBundle.getMessage(CreateSubclass.class, typeElement.getKind() == ElementKind.CLASS
            ? typeElement.getModifiers().contains(Modifier.ABSTRACT) ? "ERR_ImplementAbstractClass" : "ERR_CreateSubclass" : "ERR_ImplementInterface"), fix); //NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:65,代碼來源:CreateSubclass.java

示例14: isImplementing

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

示例15: isInterfaceDefaultMethod

public boolean isInterfaceDefaultMethod() {
  return element.getEnclosingElement().getKind() == ElementKind.INTERFACE
      && !element.getModifiers().contains(Modifier.ABSTRACT);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:ValueAttribute.java


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