/** * Drop from the end of the argument list a number of arguments. * * @param count the number of arguments to drop * @return a new Binder */ public Binder dropFirst(int count) { assert count <= type().parameterCount(); return drop(0, count); }
/** * Cast the incoming arguments to the given MethodType. The casts * applied are equivalent to those in MethodHandle.explicitCastArguments(MethodType). * * @param returnType the target return type * @param firstType the first argument type, usually a target type * @param restTypes the remaining target argument types * @return a new Binder */ public Binder castVirtual(Class<?> returnType, Class<?> firstType, Class<?>... restTypes) { return new Binder(this, new Cast(type()), MethodType.methodType(returnType, firstType, restTypes)); }
/** * Cast the incoming arguments to the given MethodType. The casts * applied are equivalent to those in MethodHandle.explicitCastArguments(MethodType). * * @param returnType the target return type * @param argTypes the target argument types * @return a new Binder */ public Binder cast(Class<?> returnType, Class<?>... argTypes) { return new Binder(this, new Cast(type()), MethodType.methodType(returnType, argTypes)); }
/** * Convert the incoming arguments to the given MethodType. The conversions * applied are equivalent to those in MethodHandle.asType(MethodType). * * @param returnType the target return type * @param argTypes the target argument types * @return a new Binder */ public Binder convert(Class<?> returnType, Class<?>... argTypes) { return new Binder(this, new Convert(type()), MethodType.methodType(returnType, argTypes)); }
/** * Convert the incoming arguments to the given MethodType. The conversions * applied are equivalent to those in MethodHandle.asType(MethodType). * * @param target the target MethodType * @return a new Binder */ public Binder convert(MethodType target) { return new Binder(this, new Convert(type()), target); }
/** * Box a range of incoming arguments into the given array type. * * @param index the index from which to start boxing args * @param count the count of arguments to box * @param type the array type into which the args will be boxed * @return a new Binder */ public Binder collect(int index, int count, Class<?> type) { return new Binder(this, new Collect(type(), index, count, type)); }
/** * Apply the chain of transforms and bind them to an array element set. The signature * at the endpoint must return void and receive the array type, int index, and array * element type. * * @return the full handle chain, bound to an array element set. */ public MethodHandle arraySet() { return invoke(MethodHandles.arrayElementSetter(type().parameterType(0))); }
/** * Process the incoming arguments by calling the given method on the first * argument, inserting the result as the first argument. * * @param lookup the java.lang.invoke.MethodHandles.Lookup to use * @param method the method to invoke on the first argument * @return a new Binder */ public Binder foldVirtual(MethodHandles.Lookup lookup, String method) { return fold(Binder.from(type()).invokeVirtualQuiet(lookup, method)); }
/** * Cast the incoming arguments to the given MethodType. The casts * applied are equivalent to those in MethodHandles.explicitCastArguments(mh, MethodType). * * @param type the target MethodType * @return a new Binder */ public Binder cast(MethodType type) { return new Binder(this, new Cast(type()), type); }
/** * Box all incoming arguments from the given position onward into the given array type. * * @param index the index from which to start boxing args * @param type the array type into which the args will be boxed * @return a new Binder */ public Binder collect(int index, Class<?> type) { return new Binder(this, new Collect(type(), index, type)); }
/** * Apply the chain of transforms and bind them to an array element get. The signature * at the endpoint must return the array element type and receive the array type and * int index. * * @return the full handle chain, bound to an array element get. */ public MethodHandle arrayGet() { return invoke(MethodHandles.arrayElementGetter(type().parameterType(0))); }
/** * Apply the chain of transforms and bind them to an array varhandle operation. The * signature at the endpoint must match the VarHandle access type passed in. */ public MethodHandle arrayAccess(VarHandle.AccessMode mode) { return invoke(MethodHandles.arrayElementVarHandle(type().parameterType(0)).toMethodHandle(mode)); }
/** * Append to the argument list the given argument value(s). * * @param values the value(s) to append * @return a new Binder */ public Binder append(Object... values) { return new Binder(this, new Insert(type().parameterCount(), values)); }
/** * Append to the argument list the given short value. * * @param value the value to append * @return a new Binder */ public Binder append(short value) { return new Binder(this, new Insert(type().parameterCount(), value)); }
/** * Append to the argument list the given float value. * * @param value the value to append * @return a new Binder */ public Binder append(float value) { return new Binder(this, new Insert(type().parameterCount(), value)); }
/** * Append to the argument list the given double value. * * @param value the value to append * @return a new Binder */ public Binder append(double value) { return new Binder(this, new Insert(type().parameterCount(), value)); }
/** * Append to the argument list the given argument value with the specified type. * * @param type the actual type to use, rather than getClass * @param value the value to append * @return a new Binder */ public Binder append(Class<?> type, Object value) { return new Binder(this, new Insert(type().parameterCount(), new Class[]{type}, value)); }
/** * Append to the argument list the given int value. * * @param value the value to append * @return a new Binder */ public Binder append(int value) { return new Binder(this, new Insert(type().parameterCount(), value)); }
/** * Append to the argument list the given argument values with the specified types. * * @param types the actual types to use, rather than getClass * @param values the value(s) to append * @return a new Binder */ public Binder append(Class<?>[] types, Object... values) { return new Binder(this, new Insert(type().parameterCount(), types, values)); }