void bindInvocation(Method method, Object[] args) { if (!method.isAccessible()) method.setAccessible(true); bindInvocation(new InvokableMethod(method),args); }
/** * Defines the method invoked by this closure. * @param closedObject The object on which the closure has to be invoked. It can be a fixed object or a Class. * In this last case, if the method is not static, it is treated as it was an * unbound argument defined through the {@link ch.lambdaj.Lambda#var(Class)} method * @param methodName The name of the method invoked by this closure or {@link AbstractClosure#CONSTRUCTOR} * if you want to call a constructor * @param args The arguments used to invoke this closure. They can be a mixed of fixed value and * unbound one defined through the {@link ch.lambdaj.Lambda#var(Class)} method * @return The closure itself */ protected AbstractClosure of(Object closedObject, String methodName, Object ... args) { Class<?> closedClass = closedObject instanceof Class<?> ? (Class<?>)closedObject : closedObject.getClass(); Invokable invokable = methodName.equals(CONSTRUCTOR) ? new InvokableConstructor(findConstructor(closedClass, args)) : new InvokableMethod(findMethod(closedClass, methodName, args)); bindInvocation(invokable, args); setClosed(invokable.isStatic() ? null : closedObject); return this; }