java.lang.reflect.AnnotatedElement#getAnnotationsByType ( )源码实例Demo

下面列出了java.lang.reflect.AnnotatedElement#getAnnotationsByType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jsonstream   文件: StringValidator.java
public StringValidator(AnnotatedElement ae) {
    required = ae.isAnnotationPresent(Required.class);
    minLength = ae.isAnnotationPresent(MinLength.class)
            ? ae.getAnnotation(MinLength.class).value() : null;
    maxLength = ae.isAnnotationPresent(MaxLength.class)
            ? ae.getAnnotation(MaxLength.class).value() : null;
    pattern = ae.isAnnotationPresent(Pattern.class)
            ? java.util.regex.Pattern.compile(ae.getAnnotation(Pattern.class).value()) : null;
    enums = ae.isAnnotationPresent(EnumString.class)
            ? new HashSet<String>(Arrays.asList(ae.getAnnotation(EnumString.class).value())) : null;
    Format[] formatAnnos = ae.getAnnotationsByType(Format.class);
    formats = new StringFormat[formatAnnos.length];
    for (int i=0; i<formatAnnos.length; i++) {
        formats[i] = newStringFormat(formatAnnos[i].value());
    }
}
 
源代码2 项目: jsonstream   文件: StringValidator.java
public StringValidator(AnnotatedElement ae) {
    required = ae.isAnnotationPresent(Required.class);
    minLength = ae.isAnnotationPresent(MinLength.class)
            ? ae.getAnnotation(MinLength.class).value() : null;
    maxLength = ae.isAnnotationPresent(MaxLength.class)
            ? ae.getAnnotation(MaxLength.class).value() : null;
    pattern = ae.isAnnotationPresent(Pattern.class)
            ? java.util.regex.Pattern.compile(ae.getAnnotation(Pattern.class).value()) : null;
    enums = ae.isAnnotationPresent(EnumString.class)
            ? new HashSet<String>(Arrays.asList(ae.getAnnotation(EnumString.class).value())) : null;
    Format[] formatAnnos = ae.getAnnotationsByType(Format.class);
    formats = new StringFormat[formatAnnos.length];
    for (int i=0; i<formatAnnos.length; i++) {
        formats[i] = newStringFormat(formatAnnos[i].value());
    }
}
 
源代码3 项目: hasor   文件: AopInterceptor.java
private List<Class<? extends MethodInterceptor>> collectAnno(AnnotatedElement element) {
    Aop[] annoSet = element.getAnnotationsByType(Aop.class);
    if (annoSet == null) {
        annoSet = new Aop[0];
    }
    return Arrays.stream(annoSet).flatMap(//
            (Function<Aop, Stream<Class<? extends MethodInterceptor>>>) aop -> Arrays.stream(aop.value())//
    ).collect(Collectors.toList());
}
 
源代码4 项目: j2objc   文件: AnnotatedElementTestSupport.java
/**
 * Asserts that {@link AnnotatedElement#getAnnotationsByType(Class)} returns the
 * expected result. The result is specified using a String. See
 * {@link AnnotatedElementTestSupport} for the string syntax.
 */
static void assertGetAnnotationsByType(AnnotatedElement annotatedElement,
        Class<? extends Annotation> annotationType, String[] expectedAnnotationStrings)
        throws Exception {
    Annotation[] annotations = annotatedElement.getAnnotationsByType(annotationType);
    assertAnnotationsMatch(annotations, expectedAnnotationStrings);
}