@Test public void should_navigate_through_all_hierarchy_of_configurations() { final Tomcat8 tomcat8 = Tomcat8Test.class.getAnnotation(Tomcat8.class); final ChameleonTargetConfiguration chameleonTargetConfiguration = AnnotationExtractor.extract(tomcat8); assertThat(chameleonTargetConfiguration.getContainer()).isEqualTo("tomcat"); assertThat(chameleonTargetConfiguration.getVersion()).isEqualTo("8.0.0"); assertThat(chameleonTargetConfiguration.getMode()).isEqualTo(Mode.MANAGED); }
public static ChameleonTargetConfiguration extract(Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); ChameleonTargetConfiguration currentConfiguration = null; if (annotationType == ChameleonTarget.class) { ChameleonTarget chameleonTarget = (ChameleonTarget) annotation; return ChameleonTargetConfiguration.from(chameleonTarget); } final Annotation[] metaAnnotations = findAndSortAnnotations(annotation); for (Annotation metaAnnotation : metaAnnotations) { if (! metaAnnotation.annotationType().getName().startsWith("java.lang")) { final ChameleonTargetConfiguration chameleonTargetConfiguration = extract(metaAnnotation); if (currentConfiguration != null) { currentConfiguration = currentConfiguration.importConfiguration(chameleonTargetConfiguration); } else { currentConfiguration = chameleonTargetConfiguration; } } } return currentConfiguration; }
AnnotationExtractor { public static ChameleonTargetConfiguration extract(Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); ChameleonTargetConfiguration currentConfiguration = null; if (annotationType == ChameleonTarget.class) { ChameleonTarget chameleonTarget = (ChameleonTarget) annotation; return ChameleonTargetConfiguration.from(chameleonTarget); } final Annotation[] metaAnnotations = findAndSortAnnotations(annotation); for (Annotation metaAnnotation : metaAnnotations) { if (! metaAnnotation.annotationType().getName().startsWith("java.lang")) { final ChameleonTargetConfiguration chameleonTargetConfiguration = extract(metaAnnotation); if (currentConfiguration != null) { currentConfiguration = currentConfiguration.importConfiguration(chameleonTargetConfiguration); } else { currentConfiguration = chameleonTargetConfiguration; } } } return currentConfiguration; } }
AnnotationExtractor { public static ChameleonTargetConfiguration extract(Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); ChameleonTargetConfiguration currentConfiguration = null; if (annotationType == ChameleonTarget.class) { ChameleonTarget chameleonTarget = (ChameleonTarget) annotation; return ChameleonTargetConfiguration.from(chameleonTarget); } final Annotation[] metaAnnotations = findAndSortAnnotations(annotation); for (Annotation metaAnnotation : metaAnnotations) { if (! metaAnnotation.annotationType().getName().startsWith("java.lang")) { final ChameleonTargetConfiguration chameleonTargetConfiguration = extract(metaAnnotation); if (currentConfiguration != null) { currentConfiguration = currentConfiguration.importConfiguration(chameleonTargetConfiguration); } else { currentConfiguration = chameleonTargetConfiguration; } } } return currentConfiguration; }  }
AnnotationExtractor { public static ChameleonTargetConfiguration extract(Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); ChameleonTargetConfiguration currentConfiguration = null; if (annotationType == ChameleonTarget.class) { ChameleonTarget chameleonTarget = (ChameleonTarget) annotation; return ChameleonTargetConfiguration.from(chameleonTarget); } final Annotation[] metaAnnotations = findAndSortAnnotations(annotation); for (Annotation metaAnnotation : metaAnnotations) { if (! metaAnnotation.annotationType().getName().startsWith("java.lang")) { final ChameleonTargetConfiguration chameleonTargetConfiguration = extract(metaAnnotation); if (currentConfiguration != null) { currentConfiguration = currentConfiguration.importConfiguration(chameleonTargetConfiguration); } else { currentConfiguration = chameleonTargetConfiguration; } } } return currentConfiguration; }  static ChameleonTargetConfiguration extract(Annotation annotation); }
AnnotationExtractor { public static ChameleonTargetConfiguration extract(Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); ChameleonTargetConfiguration currentConfiguration = null; if (annotationType == ChameleonTarget.class) { ChameleonTarget chameleonTarget = (ChameleonTarget) annotation; return ChameleonTargetConfiguration.from(chameleonTarget); } final Annotation[] metaAnnotations = findAndSortAnnotations(annotation); for (Annotation metaAnnotation : metaAnnotations) { if (! metaAnnotation.annotationType().getName().startsWith("java.lang")) { final ChameleonTargetConfiguration chameleonTargetConfiguration = extract(metaAnnotation); if (currentConfiguration != null) { currentConfiguration = currentConfiguration.importConfiguration(chameleonTargetConfiguration); } else { currentConfiguration = chameleonTargetConfiguration; } } } return currentConfiguration; }  static ChameleonTargetConfiguration extract(Annotation annotation);  }