List of usage examples for java.lang Class getMethods
@CallerSensitive public Method[] getMethods() throws SecurityException
From source file:Main.java
static Method getMethod(Class clazz, String methodName) { final Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.getName().equals(methodName)) { method.setAccessible(true);//from w ww.j a v a2 s . c o m return method; } } return null; }
From source file:MethodInfoDemo.java
/** * __UNDOCUMENTED__/* w w w. j a v a2s .c om*/ * * @param obj * __UNDOCUMENTED__ */ public static void printMethodInfo(final Object obj) { Class type = obj.getClass(); final Method[] methods = type.getMethods(); for (int idx = 0; idx < methods.length; idx++) { System.out.println(methods[idx]); } }
From source file:MyClass.java
public static ArrayList<String> getMethodsList(Class c) { Method[] methods = c.getMethods(); ArrayList<String> methodsList = getMethodsDesciption(methods); return methodsList; }
From source file:Main.java
static public boolean printAllInform(Class clsShow) { try {// w w w . j ava 2 s .c om Method[] methods = clsShow.getMethods(); int i = 0; for (; i < methods.length; i++) { Log.e(TAG, methods[i].getName() + ";and the i is:" + i); } Field[] allFields = clsShow.getFields(); for (i = 0; i < allFields.length; i++) { Log.e(TAG, allFields[i].getName()); } } catch (Exception e) { // TODO: handle exception return false; } return true; }
From source file:Main.java
public static void printAllInform(Class clsShow) { try {/*from w w w . j ava 2 s. c o m*/ int i; for (i = 0; i < clsShow.getMethods().length; i++) { } for (i = 0; i < clsShow.getFields().length; i++) { } } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e2) { e2.printStackTrace(); } catch (Exception e3) { e3.printStackTrace(); } }
From source file:Main.java
public static boolean hasAnnotation(Class<? extends Annotation> annotation, Object object, String methodName) { try {/* www . ja v a2s . com*/ Class<? extends Object> c = object.getClass(); for (Method m : c.getMethods()) { if (m.getName().equals(methodName)) { if (m.isAnnotationPresent(annotation)) { return true; } } } } catch (Exception e) { } return false; }
From source file:Util.java
public static Method findAnnotatedMethod(Class<?> clazz, Class<? extends Annotation> annotationClass) { for (Method method : clazz.getMethods()) if (method.isAnnotationPresent(annotationClass)) return (method); return (null); }
From source file:Util.java
public static List<Method> findAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationClass) { Method[] methods = clazz.getMethods(); List<Method> annotatedMethods = new ArrayList<Method>(methods.length); for (Method method : methods) { if (method.isAnnotationPresent(annotationClass)) { annotatedMethods.add(method); }// w w w . j a v a2s . co m } return annotatedMethods; }
From source file:ReflectUtils.java
/** * Adds all static methods (from Class.getMethodCalls) to the list * @param aClass//from w ww.jav a 2 s. c om * @param list * @return number of methods added */ public static int addStaticMethods(Class aClass, List<Member> list) { Method[] methods = aClass.getMethods(); for (Method m : methods) { if (Modifier.isStatic(m.getModifiers())) { list.add(m); } } return methods.length; }
From source file:Main.java
public static <T extends Annotation> boolean hasObjectMethodWithAnnotation(final Object o, final Class<T> annotation) { final Class<?>[] interfaces = o.getClass().getInterfaces(); for (final Class<?> anInterface : interfaces) { for (final Method method : anInterface.getMethods()) { if (method.getAnnotation(annotation) != null) { return true; }// w ww. j av a2 s . c o m } } return false; }