/** * Generate an array of argument offsets based on permuting this signature * to the given signature. Repeats are permitted, and the patterns will be * matched against actual argument names using regex matching. * * @param otherArgPatterns the argument name patterns to permute * @return an array of argument offsets that will permute to the matching * argument names */ public int[] to(String... otherArgPatterns) { return to(permute(otherArgPatterns)); }
/** * Using the argument names and order in the given targetNames, permute the * arguments in this SmartBinder. Arguments may be duplicated or omitted * in the targetNames array, but all arguments in the target must be * defined in this SmartBinder. * * @param targetNames the array of names from which to derive a new argument * list * @return a new SmartBinder with the permute applied */ public SmartBinder permute(String... targetNames) { return permute(signature().permute(targetNames)); }
/** * Produce a method handle permuting the arguments in this signature using * the given permute arguments and targeting the given java.lang.invoke.MethodHandle. * * Example: * * <pre> * Signature sig = Signature.returning(String.class).appendArg("a", int.class).appendArg("b", int.class); * MethodHandle handle = handleThatTakesOneInt(); * MethodHandle newHandle = sig.permuteTo(handle, "b"); * </pre> * * @param target the method handle to target * @param permuteArgs the arguments to permute * @return a new handle that permutes appropriate positions based on the * given permute args */ public MethodHandle permuteWith(MethodHandle target, String... permuteArgs) { return MethodHandles.permuteArguments(target, methodType, to(permute(permuteArgs))); }
if (nativeSig[nativeSig.length - 1] == Block.class) { target = isStatic ? fullSig.permute("context", "self", "arg*", "block") : fullSig.permute("self", "context", "arg*", "block"); } else { target = isStatic ? fullSig.permute("context", "self", "arg*") : fullSig.permute("self", "context", "arg*"); target = fullSig.permute("self", "arg*", "block"); } else { target = fullSig.permute("self", "arg*");
if (nativeSig[nativeSig.length - 1] == Block.class) { target = isStatic ? fullSig.permute("context", "self", "arg*", "block") : fullSig.permute("self", "context", "arg*", "block"); } else { target = isStatic ? fullSig.permute("context", "self", "arg*") : fullSig.permute("self", "context", "arg*"); target = fullSig.permute("self", "arg*", "block"); } else { target = fullSig.permute("self", "arg*");