@Test public void testExtract() { CircuitBreaker circuitBreaker = AnnotationExtractor .extract(AnnotatedClass.class, CircuitBreaker.class); assertThat(circuitBreaker).isNotNull(); assertThat(circuitBreaker.name()).isEqualTo("test"); }
@Nullable public static <T extends Annotation> T extract(Class<?> targetClass, Class<T> annotationClass) { T annotation = null; if (targetClass.isAnnotationPresent(annotationClass)) { annotation = targetClass.getAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no annotation '{}'", annotationClass.getSimpleName()); annotation = targetClass.getDeclaredAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no declared annotation '{}'", annotationClass.getSimpleName()); } } } return annotation; }
AnnotationExtractor { @Nullable public static <T extends Annotation> T extract(Class<?> targetClass, Class<T> annotationClass) { T annotation = null; if (targetClass.isAnnotationPresent(annotationClass)) { annotation = targetClass.getAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no annotation '{}'", annotationClass.getSimpleName()); annotation = targetClass.getDeclaredAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no declared annotation '{}'", annotationClass.getSimpleName()); } } } return annotation; } }
AnnotationExtractor { @Nullable public static <T extends Annotation> T extract(Class<?> targetClass, Class<T> annotationClass) { T annotation = null; if (targetClass.isAnnotationPresent(annotationClass)) { annotation = targetClass.getAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no annotation '{}'", annotationClass.getSimpleName()); annotation = targetClass.getDeclaredAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no declared annotation '{}'", annotationClass.getSimpleName()); } } } return annotation; } private  AnnotationExtractor(); }
AnnotationExtractor { @Nullable public static <T extends Annotation> T extract(Class<?> targetClass, Class<T> annotationClass) { T annotation = null; if (targetClass.isAnnotationPresent(annotationClass)) { annotation = targetClass.getAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no annotation '{}'", annotationClass.getSimpleName()); annotation = targetClass.getDeclaredAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no declared annotation '{}'", annotationClass.getSimpleName()); } } } return annotation; } private  AnnotationExtractor(); @Nullable static T extract(Class<?> targetClass, Class<T> annotationClass); @Nullable static T extractAnnotationFromProxy(Object targetProxy,
        Class<T> annotationClass); }
AnnotationExtractor { @Nullable public static <T extends Annotation> T extract(Class<?> targetClass, Class<T> annotationClass) { T annotation = null; if (targetClass.isAnnotationPresent(annotationClass)) { annotation = targetClass.getAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no annotation '{}'", annotationClass.getSimpleName()); annotation = targetClass.getDeclaredAnnotation(annotationClass); if (annotation == null && logger.isDebugEnabled()) { logger.debug("TargetClass has no declared annotation '{}'", annotationClass.getSimpleName()); } } } return annotation; } private  AnnotationExtractor(); @Nullable static T extract(Class<?> targetClass, Class<T> annotationClass); @Nullable static T extractAnnotationFromProxy(Object targetProxy,
        Class<T> annotationClass);  }