ClassMate<MyClass> classMate = ClassMate.from(MyClass.class); Reflections reflections = new Reflections("com.example"); Set<Class<?>> classes = reflections.getTypesAnnotatedWith(MyAnnotation.class); ClassMate classMate = ClassMate.from(classes); List<Field> fields = classMate.getFields(); List<Method> methods = classMate.getMethods(); List<Constructor> constructors = classMate.getConstructors(); MyClass instance = classMate.newInstance(); Field field = classMate.getField("fieldName"); Object value = classMate.getValue(instance, field); Method method = classMate.getMethod("methodName"); Object result = classMate.invoke(instance, method, args); classMate.includeFields(new FieldFilter() { public boolean accept(Field field) { return field.getName().startsWith("prefix"); } }); classMate.includeMethods(new MethodFilter() { public boolean accept(Method method) { return method.getReturnType().equals(String.class); } });


上一篇:
下一篇:
切换中文