当前位置: 首页>>代码示例>>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;未经允许,请勿转载。