private static Interceptor[] resolveInterceptorsInternal(ExecutableMethod<?, ?> method, Class<? extends Annotation> annotationType, Interceptor[] interceptors) { List<Class<? extends Annotation>> annotations = method.getAnnotationTypesByStereotype(annotationType); Set<Class> applicableClasses = annotations.stream() .filter(aClass -> { if (annotationType == Around.class && aClass.getAnnotation(Introduction.class) != null) { return false; } else if (annotationType == Introduction.class && aClass.getAnnotation(Around.class) != null) { return false; } return true; }) .map(type -> type.getAnnotation(Type.class)) .filter(Objects::nonNull) .flatMap(type -> Arrays.stream(type.value()) ).collect(Collectors.toSet()); Interceptor[] interceptorArray = Arrays.stream(interceptors) .filter(i -> applicableClasses.stream().anyMatch((t) -> t.isInstance(i))) .toArray(Interceptor[]::new); OrderUtil.sort(interceptorArray); return interceptorArray; } }
/** * @param types The types */ TypeAnnotationQualifier(@Nullable Class<?>... types) { if (types != null) { this.types = new ArrayList<>(types.length); for (Class<?> type : types) { Type typeAnn = type.getAnnotation(Type.class); if (typeAnn != null) { this.types.addAll(Arrays.asList(typeAnn.value())); } else { this.types.add(type); } } } else { this.types = Collections.emptyList(); } }
/** * @param types The types */ TypeAnnotationQualifier(@Nullable Class<?>... types) { if (types != null) { this.types = new ArrayList<>(types.length); for (Class<?> type : types) { Type typeAnn = type.getAnnotation(Type.class); if (typeAnn != null) { this.types.addAll(Arrays.asList(typeAnn.value())); } else { this.types.add(type); } } } else { this.types = Collections.emptyList(); } }
private static Interceptor[] resolveInterceptorsInternal(ExecutableMethod<?, ?> method, Class<? extends Annotation> annotationType, Interceptor[] interceptors) { List<Class<? extends Annotation>> annotations = method.getAnnotationTypesByStereotype(annotationType); Set<Class> applicableClasses = annotations.stream() .filter(aClass -> { if (annotationType == Around.class && aClass.getAnnotation(Introduction.class) != null) { return false; } else if (annotationType == Introduction.class && aClass.getAnnotation(Around.class) != null) { return false; } return true; }) .map(type -> type.getAnnotation(Type.class)) .filter(Objects::nonNull) .flatMap(type -> Arrays.stream(type.value()) ).collect(Collectors.toSet()); Interceptor[] interceptorArray = Arrays.stream(interceptors) .filter(i -> applicableClasses.stream().anyMatch((t) -> t.isInstance(i))) .toArray(Interceptor[]::new); OrderUtil.sort(interceptorArray); return interceptorArray; } }
private static Interceptor[] resolveInterceptorsInternal(ExecutableMethod<?, ?> method, Class<? extends Annotation> annotationType, Interceptor[] interceptors) { List<Class<? extends Annotation>> annotations = method.getAnnotationTypesByStereotype(annotationType); Set<Class> applicableClasses = annotations.stream() .filter(aClass -> { if (annotationType == Around.class && aClass.getAnnotation(Introduction.class) != null) { return false; } else if (annotationType == Introduction.class && aClass.getAnnotation(Around.class) != null) { return false; } return true; }) .map(type -> type.getAnnotation(Type.class)) .filter(Objects::nonNull) .flatMap(type -> Arrays.stream(type.value()) ).collect(Collectors.toSet()); Interceptor[] interceptorArray = Arrays.stream(interceptors) .filter(i -> applicableClasses.stream().anyMatch((t) -> t.isInstance(i))) .toArray(Interceptor[]::new); OrderUtil.sort(interceptorArray); return interceptorArray; } }
/** * Build a qualifier for the given annotation. * * @param annotation The annotation * @param <T> The component type * @return The qualifier */ public static <T> Qualifier<T> byAnnotation(Annotation annotation) { if (annotation.annotationType() == Type.class) { Type typeAnn = (Type) annotation; return byType(typeAnn.value()); } else if (annotation.annotationType() == Named.class) { Named nameAnn = (Named) annotation; return byName(nameAnn.value()); } else { return new AnnotationQualifier<>(annotation); } }
/** * Build a qualifier for the given annotation. * * @param annotation The annotation * @param <T> The component type * @return The qualifier */ public static <T> Qualifier<T> byAnnotation(Annotation annotation) { if (annotation.annotationType() == Type.class) { Type typeAnn = (Type) annotation; return byType(typeAnn.value()); } else if (annotation.annotationType() == Named.class) { Named nameAnn = (Named) annotation; return byName(nameAnn.value()); } else { return new AnnotationQualifier<>(annotation); } }
Type annotation = type.getAnnotation(Type.class); if (annotation != null) { Class[] value = annotation.value(); for (Class aClass : value) { module.addSerializer(aClass, serializer); Type annotation = type.getAnnotation(Type.class); if (annotation != null) { Class[] value = annotation.value(); for (Class aClass : value) { module.addDeserializer(aClass, deserializer);