// This method returns public methods of same reference. public static Method[] getSameClassPublicMethods(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } List<Method> listOfMetods = new ArrayList<Method>(); Method[] meds = obj.getClass().getMethods(); Method[] med = null; for (Method m : meds) { if (m.getDeclaringClass().getName().equalsIgnoreCase(obj.getClass().getName())) { listOfMetods.add(m); } } int size = listOfMetods.size(); if (size > 0) { med = new Method[size]; for (int i = 0; i < med.length; i++) { med[i] = listOfMetods.get(i); } } return med; }
public static Package getPackage(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getPackage(); }
public static Integer getModifier(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getModifiers(); }
public static String getClassName(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getName(); }
/** * Returns an array of Method objects reflecting all the methods declared by the class or * interface represented by this Class object. This includes public, protected, default (package) * access, and private methods, but excludes inherited methods. The elements in the array returned * are not sorted and are not in any particular order. This method returns an array of length 0 if * the class or interface declares no methods, or if this Class object represents a primitive * type, an array class, or void. The class initialization method <clinit> is not included in the * returned array. If the class declares multiple public member methods with the same parameter * types, they are all included in the returned array. */ public static Method[] getAllDeclaredMethods(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getDeclaredMethods(); }
public static Class[] getImplementedInterfaces(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getInterfaces(); }
public static Class getSuperClass(Object obj) { if (NullUtils.areAnyNull(obj)) { return null; } return obj.getClass().getSuperclass(); }