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


Java AnnotationUtils.areSameByClass方法代码示例

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


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

示例1: visitVariable

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public Void visitVariable(VariableTree node, Void p) {
    // is this a field (and not a local variable)?
    if (TreeUtils.elementFromDeclaration(node).getKind().isField()) {
        Set<AnnotationMirror> annotationMirrors = atypeFactory.getAnnotatedType(
                node).getExplicitAnnotations();
        // Fields cannot have commitment annotations.
        for (Class<? extends Annotation> c : atypeFactory.getInitializationAnnotations()) {
            for (AnnotationMirror a : annotationMirrors) {
                if (atypeFactory.isUnclassified(a)) continue; // unclassified is allowed
                if (AnnotationUtils.areSameByClass(a, c)) {
                    checker.report(Result.failure(
                            COMMITMENT_INVALID_FIELD_ANNOTATION, node),
                            node);
                    break;
                }
            }
        }
    }
    return super.visitVariable(node, p);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:22,代码来源:InitializationVisitor.java

示例2: visitMethod

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public Void visitMethod(MethodTree node, Void p) {
    if (TreeUtils.isConstructor(node)) {
        Collection<? extends AnnotationMirror> returnTypeAnnotations = getExplicitReturnTypeAnnotations(node);
        // check for invalid constructor return type
        for (Class<? extends Annotation> c : atypeFactory.getInvalidConstructorReturnTypeAnnotations()) {
            for (AnnotationMirror a : returnTypeAnnotations) {
                if (AnnotationUtils.areSameByClass(a, c)) {
                    checker.report(Result.failure(
                            COMMITMENT_INVALID_CONSTRUCTOR_RETURN_TYPE,
                            node), node);
                    break;
                }
            }
        }

        // Check that all fields have been initialized at the end of the
        // constructor.
        boolean isStatic = false;
        Store store = atypeFactory.getRegularExitStore(node);
        List<? extends AnnotationMirror> receiverAnnotations = getAllReceiverAnnotations(node);
        checkFieldsInitialized(node, isStatic, store, receiverAnnotations);
    }
    return super.visitMethod(node, p);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:26,代码来源:InitializationVisitor.java

示例3: annoIsPresented

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean annoIsPresented(AnnotationMirror anno) {
    if (AnnotationUtils.areSameByClass(anno, DataFlowTop.class)) {
        return true;
    }
    String[] datatypes;
    if (this.isRoot) {
        datatypes = DataflowUtils.getTypeNameRoots(anno);
    } else {
        datatypes = DataflowUtils.getTypeNames(anno);
    }

    return Arrays.asList(datatypes).contains(datatype);
}
 
开发者ID:Jianchu,项目名称:generic-type-inference-solver,代码行数:14,代码来源:DataflowSerializer.java

示例4: annoIsPresented

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean annoIsPresented(AnnotationMirror anno) {
    if (AnnotationUtils.areSameByClass(anno, DataFlowTop.class)) {
        return true;
    }
    String[] datatypes = DataflowUtils.getTypeNames(anno);
    String[] datatype = DataflowUtils.getTypeNames(this.lattice.top);
    return Arrays.asList(datatypes).contains(datatype[0]);
}
 
开发者ID:Jianchu,项目名称:generic-type-inference-solver,代码行数:9,代码来源:DataflowGeneralSerializer.java

示例5: containsSameIgnoringValues

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean containsSameIgnoringValues(
        Set<Class<? extends Annotation>> quals, AnnotationMirror anno) {
    for (Class<? extends Annotation> q : quals) {
        if (AnnotationUtils.areSameByClass(anno, q)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:10,代码来源:NullnessVisitor.java

示例6: getDeclAnnotationWithMetaAnnotation

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Returns a list of all declaration annotations used to annotate this element,
 * which have a meta-annotation (i.e., an annotation on that annotation)
 * with class {@code metaAnnotation}.
 *
 * @param element
 *            The element for which to determine annotations.
 * @param metaAnnotation
 *            The meta annotation that needs to be present.
 * @return A list of pairs {@code (anno, metaAnno)} where {@code anno} is
 *         the annotation mirror at {@code element}, and {@code metaAnno} is
 *         the annotation mirror used to annotate {@code anno}.
 */
public List<Pair<AnnotationMirror, AnnotationMirror>> getDeclAnnotationWithMetaAnnotation(
        Element element, Class<? extends Annotation> metaAnnotation) {
    List<Pair<AnnotationMirror, AnnotationMirror>> result = new ArrayList<>();
    List<AnnotationMirror> annotationMirrors = new ArrayList<>();

    // Consider real annotations.
    annotationMirrors.addAll(element.getAnnotationMirrors());

    // Consider stub annotations.
    String eltName = ElementUtils.getVerboseName(element);
    Set<AnnotationMirror> stubAnnos = indexDeclAnnos.get(eltName);
    if (stubAnnos != null) {
        annotationMirrors.addAll(stubAnnos);
    }

    // Go through all annotations found.
    for (AnnotationMirror annotation : annotationMirrors) {
        List<? extends AnnotationMirror> annotationsOnAnnotation;
        try {
            annotationsOnAnnotation = annotation.getAnnotationType().asElement().getAnnotationMirrors();
        } catch (com.sun.tools.javac.code.Symbol.CompletionFailure cf) {
            // Fix for Issue 309: If a CompletionFailure occurs, issue a warning.
            // I didn't find a nicer alternative to check whether the Symbol can be completed.
            // The completer field of a Symbol might be non-null also in successful cases.
            // Issue a warning (exception only happens once) and continue.
            checker.message(Kind.WARNING, annotation.getAnnotationType().asElement(),
                    "annotation.not.completed", ElementUtils.getVerboseName(element), annotation);
            continue;
        }
        // First call copier, if exception, continue normal modula laws.
        for (AnnotationMirror a : annotationsOnAnnotation) {
            if (AnnotationUtils.areSameByClass(a, metaAnnotation)) {
                result.add(Pair.of(annotation, a));
            }
        }
    }
    return result;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:52,代码来源:AnnotatedTypeFactory.java

示例7: getAnnotationWithMetaAnnotation

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Returns a list of all annotations used to annotate this element,
 * which have a meta-annotation (i.e., an annotation on that annotation)
 * with class {@code metaAnnotation}.
 *
 * @param element
 *            The element at which to look for annotations.
 * @param metaAnnotation
 *            The meta annotation that needs to be present.
 * @return A list of pairs {@code (anno, metaAnno)} where {@code anno} is
 *         the annotation mirror at {@code element}, and {@code metaAnno} is
 *         the annotation mirror used to annotate {@code anno}.
 */
public List<Pair<AnnotationMirror, AnnotationMirror>> getAnnotationWithMetaAnnotation(
        Element element, Class<? extends Annotation> metaAnnotation) {
    List<Pair<AnnotationMirror, AnnotationMirror>> result = new ArrayList<>();
    List<AnnotationMirror> annotationMirrors = new ArrayList<>();

    // Consider real annotations.
    annotationMirrors.addAll(getAnnotatedType(element).getAnnotations());

    // Consider stub annotations.
    String eltName = ElementUtils.getVerboseName(element);
    Set<AnnotationMirror> stubAnnos = indexDeclAnnos.get(eltName);
    if (stubAnnos != null) {
        annotationMirrors.addAll(stubAnnos);
    }

    // Go through all annotations found.
    for (AnnotationMirror annotation : annotationMirrors) {
        List<? extends AnnotationMirror> annotationsOnAnnotation = annotation
                .getAnnotationType().asElement().getAnnotationMirrors();
        for (AnnotationMirror a : annotationsOnAnnotation) {
            if (AnnotationUtils.areSameByClass(a, metaAnnotation)) {
                result.add(Pair.of(annotation, a));
            }
        }
    }
    return result;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:41,代码来源:AnnotatedTypeFactory.java

示例8: getAnnotation

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Returns the actual annotation mirror used to annotate this type,
 * whose name equals the passed annotationName if one exists, null otherwise.
 *
 * @param annoClass annotation class
 * @return the annotation mirror for anno
 */
public AnnotationMirror getAnnotation(Class<? extends Annotation> annoClass) {
    for (AnnotationMirror annoMirror : getAnnotations()) {
        if (AnnotationUtils.areSameByClass(annoMirror, annoClass)) {
            return annoMirror;
        }
    }
    return null;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:16,代码来源:AnnotatedTypeMirror.java

示例9: isUnclassified

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Is {@code anno} the {@link UnknownInitialization} annotation (with any type
 * frame)? If {@code useFbc} is false, then {@link Raw} is used in the
 * comparison.
 */
public boolean isUnclassified(AnnotationMirror anno) {
    Class<? extends Annotation> clazz = useFbc ? UnknownInitialization.class
            : Raw.class;
    return AnnotationUtils.areSameByClass(anno, clazz);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:11,代码来源:InitializationAnnotatedTypeFactory.java

示例10: noUnits

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean noUnits(AnnotatedTypeMirror t) {
    Set<AnnotationMirror> annos = t.getAnnotations();
    return annos.isEmpty() ||
            (annos.size() == 1 &&
            AnnotationUtils.areSameByClass(annos.iterator().next(), UnknownUnits.class));
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:7,代码来源:UnitsAnnotatedTypeFactory.java

示例11: isPolyAll

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public static boolean isPolyAll(AnnotationMirror qual) {
    return AnnotationUtils.areSameByClass(qual, PolyAll.class);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:4,代码来源:QualifierPolymorphism.java

示例12: isFree

import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
 * Is {@code anno} the {@link UnderInitialization} annotation (with any type frame)? Always
 * returns false if {@code useFbc} is false.
 */
public boolean isFree(AnnotationMirror anno) {
    return useFbc && AnnotationUtils.areSameByClass(anno, UnderInitialization.class);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:8,代码来源:InitializationAnnotatedTypeFactory.java


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