@
CantSee #21 兄弟你给力,不过你这样违法了开闭原则吧,我后期加类型还是要在这里加代码
我用这样的方式实现了
```java
public Type getTypeService(int type) {
Reflections reflections = new Reflections("com.xxxx");
Set<Class<?>> classSet = reflections.getTypesAnnotatedWith(CustomAnnotation.class);
for (Class<?> aClass : classSet) {
CustomAnnotation annotation = aClass.getAnnotation(CustomAnnotation.class);
if (type == CustomAnnotation.type()) {
try {
return (Type) aClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
throw new Exc("msg");
}
}
}
throw new Exc("msg");
}
```