AnnotationUtils { public static String annotatedName(Class<?> clazz) { if (AlgoOperator.class.isAssignableFrom(clazz)) { IoOpAnnotation annotation = clazz.getAnnotation(IoOpAnnotation.class); return annotation == null ? null : annotation.name(); } else if (BaseDB.class.isAssignableFrom(clazz)) { DBAnnotation annotation = clazz.getAnnotation(DBAnnotation.class); return annotation == null ? null : annotation.name(); } else if (BaseFileSystem.class.isAssignableFrom(clazz)) { FSAnnotation annotation = clazz.getAnnotation(FSAnnotation.class); return annotation == null ? null : annotation.name(); } else { throw new IllegalStateException( "Only DB and IO Operator class have annotated name: " + clazz.getCanonicalName()); } }  static String annotatedName(Class<?> clazz); static String annotatedAlias(Class<? extends BaseDB> cls); static String annotatedAlias(String name); static IOType annotatedIoType(Class<? extends AlgoOperator> cls); static ParamInfo<String> tableAliasParamKey(String name); static ParamInfo<String> tableAliasParamKey(Class<? extends BaseDB> dbClazz); static ParamInfo<String> dynamicParamKey(String key); static List<String> allDBAndOpNames(); static List<String> allFileSystemNames(); static BaseDB createDB(String name, Params parameter); static BaseFileSystem<?> createFileSystem(String name, Params parameter); static boolean isDB(String name); static boolean isDBHasTimestamp(String name); static boolean isIoOpHasTimestamp(String name, IOType type); static boolean isFileSystem(String name); static AlgoOperator createOp(String name, IOType type, Params parameter);  }
@Test public void testAnnotatedName() { Assert.assertEquals("test_fake_db_1", AnnotationUtils.annotatedName(FakeDB1.class)); Assert.assertEquals("test_fake_db_2", AnnotationUtils.annotatedName(FakeDB2.class)); Assert.assertEquals("test_fake_op_1", AnnotationUtils.annotatedName(FakeOp1.class)); Assert.assertEquals("test_fake_op_2", AnnotationUtils.annotatedName(FakeOp2.class)); }
@Test(expected = IllegalStateException.class) public void testAnnotatedNameException() { AnnotationUtils.annotatedName(DummyClass1.class); }