### Question:
AnnotationHandler { public <T> Optional<T> getInstance(Class targetClass, Class annotationClass) { Optional optional = Optional.empty(); Object object; try { object = targetClass.newInstance(); object = checkAnnotation(object, annotationClass); optional = Optional.of(object); } catch (InstantiationException | IllegalAccessException e) { System.out.println(e.getMessage()); } return optional; }  Optional<T> getInstance(Class targetClass, Class annotationClass);  }### Answer:
@Test public void name() { AnnotationHandler handler = new AnnotationHandler(); AnnotationExam01 exam01 = handler.getInstance(AnnotationExam01.class, InsertIntData.class) .map(o -> (AnnotationExam01) o) .orElse(new AnnotationExam01()); AnnotationExam02 exam02 = handler.getInstance(AnnotationExam02.class, InsertStringData.class) .map(o -> (AnnotationExam02) o) .orElse(new AnnotationExam02()); assertEquals(30, exam01.getMyAge()); assertEquals(0, exam01.getDefaultAge()); assertEquals("MHLab", exam02.getMyData()); assertEquals(null, exam02.getDefaultData()); }