/** * Gets the all method except. * * @param <T> the generic type * @param type the type * @param methodNames the method names * @return the all method except */ public static <T> Method[] getAllMethodExcept(Class<T> type, String... methodNames) { List<Method> methodsToMock = new LinkedList<Method>(); Method[] methods = getAllMethods(type); iterateMethods: for (Method method : methods) { for (String methodName : methodNames) { if (method.getName().equals(methodName)) { continue iterateMethods; } } methodsToMock.add(method); } return methodsToMock.toArray(new Method[0]); }
/** * Get all methods in a class hierarchy of the supplied classes. Both * declared an non-declared (no duplicates). * * @param cls * The class whose methods to get. * @param additionalClasses * Additional classes whose methods to get. * @return All methods declared in this class hierarchy. */ public static Method[] methodsDeclaredIn(final Class<?> cls, final Class<?>... additionalClasses) { if (cls == null) { throw new IllegalArgumentException("You need to supply at least one class."); } Set<Method> methods = new HashSet<Method>(); methods.addAll(asList(WhiteboxImpl.getAllMethods(cls))); for (Class<?> klass : additionalClasses) { methods.addAll(asList(WhiteboxImpl.getAllMethods(klass))); } return methods.toArray(new Method[methods.size()]); }
/** * Get all methods in a class hierarchy of the supplied classes. Both * declared an non-declared (no duplicates). * * @param cls * The class whose methods to get. * @param additionalClasses * Additional classes whose methods to get. * @return All methods declared in this class hierarchy. */ public static Method[] methodsDeclaredIn(final Class<?> cls, final Class<?>... additionalClasses) { if (cls == null) { throw new IllegalArgumentException("You need to supply at least one class."); } Set<Method> methods = new HashSet<Method>(); methods.addAll(asList(WhiteboxImpl.getAllMethods(cls))); for (Class<?> klass : additionalClasses) { methods.addAll(asList(WhiteboxImpl.getAllMethods(klass))); } return methods.toArray(new Method[methods.size()]); }
/** * Gets the all method except. * * @param <T> * the generic type * @param type * the type * @param methodNames * the method names * @return the all method except */ public static <T> Method[] getAllMethodExcept(Class<T> type, String... methodNames) { List<Method> methodsToMock = new LinkedList<Method>(); Method[] methods = getAllMethods(type); iterateMethods: for (Method method : methods) { for (String methodName : methodNames) { if (method.getName().equals(methodName)) { continue iterateMethods; } } methodsToMock.add(method); } return methodsToMock.toArray(new Method[0]); }
Method[] methods = getAllMethods(type); List<Method> methodList = new ArrayList<Method>(); outer: for (Method method : methods) {
Method[] methods = getAllMethods(type); List<Method> methodList = new ArrayList<Method>(); outer:
for (Method method : getAllMethods(type)) { if (methodName == null || method.getName().equals(methodName)) { if (parameterTypes != null && parameterTypes.length > 0) {
allMethods = getAllPublicMethods(clazz); } else { allMethods = getAllMethods(clazz);
allMethods = getAllPublicMethods(clazz); } else { allMethods = getAllMethods(clazz);
for (Method method : getAllMethods(type)) { if (methodName == null || method.getName().equals(methodName)) { if (parameterTypes != null && parameterTypes.length > 0) {
methods = getAllMethods(testedType); } else { methods = declaringClass.getDeclaredMethods();
methods = getAllMethods(testedType); } else { methods = declaringClass.getDeclaredMethods();