@Override public Object invoke(Invocation invocation) throws Throwable { return (Integer) invocation.getParameter(0);
@Override public Object invoke(Invocation invocation) throws Throwable { if(invocation.getParameterCount() != 1) { throw new IllegalArgumentException("intended for action of findByXxx"); } final Object argObj = invocation.getParameter(0); if(!(argObj instanceof String)) { throw new IllegalArgumentException("Argument must be a string"); } String arg = (String) argObj; return getElseCreate(cls, arg); }
@Override public Object invoke(final Invocation invocation) throws Throwable { return invocation.getParameter(i); }
private void defineParameters(Interpreter interpreter, Invocation invocation) throws EvalError { interpreter.set("$this", invocation.getInvokedObject()); for (int i = 0; i < invocation.getParameterCount(); i++) { interpreter.set("$" + i, invocation.getParameter(i)); } }
public Object invoke(final Invocation invocation) throws Throwable { return invocation.getParameter(i); } }
private void defineParameters(Interpreter interpreter, Invocation invocation) throws EvalError { interpreter.set("$this", invocation.getInvokedObject()); for (int i = 0; i < invocation.getParameterCount(); i++) { interpreter.set("$" + i, invocation.getParameter(i)); } }
@Override public Object invoke(Invocation invocation) throws Throwable { Class<?> cls = (Class<?>) invocation.getParameter(0); return cls.newInstance(); } };
@Override public Object invoke(Invocation invocation) throws Throwable { variables.put(variableName, invocation.getParameter(parameterIndex)); return null; } };
@SuppressWarnings("unchecked") @Override public Object invoke(Invocation invocation) throws Throwable { parameterStorage.set((T) invocation.getParameter(parameterIndex)); return null; } };
@Override public Object invoke(Invocation invocation) throws Throwable { byte[] destBytes = (byte[]) invocation.getParameter(0); int bytesCopied = Math.min(destBytes.length, srcBytes.length); System.arraycopy(srcBytes, 0, destBytes, 0, bytesCopied); return bytesCopied; } }
@Override public Object invoke(Invocation invocation) throws Throwable { ((IoSession)invocation.getParameter(parameterIndex)).close(false); return null; } };
@Override public Object invoke(final Invocation invocation) throws Throwable { final Object injectable = invocation.getInvokedObject(); final Object toInjectInto = invocation.getParameter(0); final Method[] methods = toInjectInto.getClass().getMethods(); for (final Method method : methods) { if (!method.getName().startsWith("set")) { continue; } if (method.getParameterTypes().length != 1) { continue; } final Class<?> methodParameterType = method.getParameterTypes()[0]; if (methodParameterType.isAssignableFrom(injectable.getClass())) { method.invoke(toInjectInto, injectable); break; } } return null; }
@Override public Object invoke(final Invocation invocation) throws Throwable { final Object injectable = invocation.getInvokedObject(); final Object toInjectInto = invocation.getParameter(0); final Method[] methods = toInjectInto.getClass().getMethods(); for (final Method method : methods) { if (!method.getName().startsWith("set")) { continue; } if (method.getParameterTypes().length != 1) { continue; } final Class<?> methodParameterType = method.getParameterTypes()[0]; if (methodParameterType.isAssignableFrom(injectable.getClass())) { method.invoke(toInjectInto, injectable); break; } } return null; }
@SuppressWarnings("unchecked") public Object invoke(Invocation invocation) throws Throwable { ((Collection<Object>)invocation.getParameter(0)).add(newElement); return null; }
public Object invoke(Invocation invocation) throws Throwable { Method method = invocation.getInvokedMethod(); if (isMethod(method, int.class, "hashCode")) { return fakeHashCode(invocation.getInvokedObject()); } else if (isMethod(method, String.class, "toString")) { return fakeToString(invocation.getInvokedObject()); } else if (isMethod(method, boolean.class, "equals", Object.class)) { return fakeEquals(invocation.getInvokedObject(), invocation.getParameter(0)); } else if (isMethod(method, void.class, "finalize")) { fakeFinalize(invocation.getInvokedObject()); return null; } else { return next.invoke(invocation); } }