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


Java AnnotatedType.getAnnotations方法代码示例

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


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

示例1: testReturnsEmptyAT

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private static void testReturnsEmptyAT() {
    for (Class<?> toTest : nonNullTestData) {
        tests++;

        AnnotatedType res = toTest.getAnnotatedSuperclass();

        if (res == null) {
            failed++;
            System.out.println(toTest + ".getAnnotatedSuperclass() returns 'null' should  be non-null");
        } else if (res.getAnnotations().length != 0) {
            failed++;
            System.out.println(toTest + ".getAnnotatedSuperclass() returns: "
                    + Arrays.asList(res.getAnnotations()) + ", should be an empty AnnotatedType");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:GetAnnotatedSuperclass.java

示例2: verifyArrayFieldTypeAnnotations

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:RedefineAnnotations.java

示例3: build

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
public static Set<ContainerElementTypeDescriptor> build(
        final Class<?> elementClass,
        final AnnotatedParameterizedType annotatedType) {

    final Set<ContainerElementTypeDescriptor> result = new HashSet<>();
    final Class<?> containerClass = ReflectionUtils.getRawType(annotatedType);
    int argIndex = 0;

    for (final AnnotatedType typeArg : annotatedType.getAnnotatedActualTypeArguments()) {
        final Set<ConstraintDescriptor<?>> constraintDescriptors = new HashSet<>();

        for (final Annotation annotation : typeArg.getAnnotations()) {
            final MinijaxConstraintDescriptor<?> constraintDescriptor = MinijaxConstraintDescriptor.build(typeArg, annotation);
            if (constraintDescriptor != null) {
                constraintDescriptors.add(constraintDescriptor);
            }
        }

        if (!constraintDescriptors.isEmpty()) {
            result.add(new MinijaxContainerElementTypeDescriptor(elementClass, containerClass, argIndex, constraintDescriptors));
        }

        argIndex++;
    }

    return result;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:28,代码来源:MinijaxContainerElementTypeDescriptor.java

示例4: checkEmptyAT

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private static void checkEmptyAT(AnnotatedType a, String msg) {
    if (a.getAnnotations().length != 0) {
        failures++;
        System.err.print(msg);
    }
    tests++;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:GetAnnotatedReceiverType.java

示例5: verifyInnerFieldTypeAnnotations

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private void verifyInnerFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    AnnotatedType at = c.getDeclaredField("typeAnnotatedInner").getAnnotatedType();
    Annotation anno = at.getAnnotations()[0];
    verifyTestAnn(innerTA, anno, "inner");
    innerTA = anno;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:RedefineAnnotations.java

示例6: verifyMapFieldTypeAnnotations

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private void verifyMapFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType atBase;
    AnnotatedType atParameter;
    atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();

    anno = atBase.getAnnotations()[0];
    verifyTestAnn(mapTA[0], anno, "map1");
    mapTA[0] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[0];
    anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[1], anno, "map2");
    mapTA[1] = anno;

    anno =
        ((AnnotatedWildcardType) atParameter).
        getAnnotatedUpperBounds()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[2], anno, "map3");
    mapTA[2] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[1];
    anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[3], anno, "map4");
    mapTA[3] = anno;

    anno =
        ((AnnotatedParameterizedType) atParameter).
        getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[4], anno, "map5");
    mapTA[4] = anno;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:RedefineAnnotations.java

示例7: checkEmptyAT

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private static void checkEmptyAT(Executable e, String msg) {
    AnnotatedType a = e.getAnnotatedReceiverType();
    if (a.getAnnotations().length != 0) {
        failures++;
        System.err.print(msg + ": " + e);
    }
    tests++;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:GetAnnotatedReceiverType.java

示例8: checkApiRules

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private void checkApiRules(Class<?> publicClass) {
    List<Class<?>> declaredClasses = publicClasses(publicClass.getDeclaredClasses());
    if (!declaredClasses.isEmpty()) {
        throw new IllegalStateException("There are no inner classes in the public API");
    }

    Class<?> componentType = publicClass.getComponentType();
    if (componentType != null) {
        throw new IllegalStateException("There are no array classes in the public API");
    }

    AnnotatedType annotatedSuperclass = publicClass.getAnnotatedSuperclass();
    if (annotatedSuperclass != null && annotatedSuperclass.getAnnotations().length > 0) {
        throw new IllegalStateException("There are no annotated super classes in the public API");
    }

    AnnotatedType[] annotatedInterfaces = publicClass.getAnnotatedInterfaces();
    for (AnnotatedType annotatedInterface : annotatedInterfaces) {
        if (annotatedInterface.getAnnotations().length > 0) {
            throw new IllegalStateException("There are no annotated interfaces in the public API");
        }
    }

    List<Constructor<?>> declaredConstructors = publicConstructors(publicClass.getDeclaredConstructors());
    if (!declaredConstructors.isEmpty()) {
        throw new IllegalStateException("There are no constructors in the public API");
    }

    Method[] declaredMethods = publicClass.getDeclaredMethods();
    if (existProtectedElements(stream(declaredMethods), Method::getModifiers)) {
        throw new IllegalStateException("There are no protected methods in the public API");
    }

    Field[] declaredFields = publicClass.getDeclaredFields();
    if (existProtectedElements(stream(declaredFields), Field::getModifiers)) {
        throw new IllegalStateException("There are no protected fields in the public API");
    }
}
 
开发者ID:theangrydev,项目名称:business-flows,代码行数:39,代码来源:PublicApiTest.java

示例9: removeNonNull

import java.lang.reflect.AnnotatedType; //导入方法依赖的package包/类
private AnnotatedType removeNonNull(AnnotatedType type) {
    Collection<Annotation> keptAnnotations = new ArrayList<>(type.getAnnotations().length - 1);
    for (Annotation annotation : type.getAnnotations()) {
        if (!nonNullAnnotations.contains(annotation.annotationType())) {
            keptAnnotations.add(annotation);
        }
    }
    return GenericTypeReflector.replaceAnnotations(type, keptAnnotations.toArray(new Annotation[keptAnnotations.size()]));
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:10,代码来源:NonNullMapper.java


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