Top Description Fields Constructors Methods
com.headius.invokebinder

public Class Binder

extends Object
Class Inheritance
Imports
com.headius.invokebinder.transform.Cast, .Catch, .Collect, .Convert, .Drop, .Filter, .FilterReturn, .Fold, .Insert, .Permute, .Spread, .Transform, .TryFinally, .Varargs, java.io.PrintStream, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, .VarHandle, java.lang.reflect.Method, java.util.Arrays, .LinkedList, .List, .ListIterator, java.util.logging.Logger

The Binder class provides a DSL for building a chain of MethodHandles using various of the adaptations provided by java.lang.invoke.MethodHandles. The transformations are pushed into a stack, allowing the DSL to operate forward from an incoming signature rather than backward from a target handle. This is often conceptually easier to understand, and certainly easier to read. The transformations are also applied simultaneously to the starting java.lang.invoke.MethodType, allowing Binder to check at each step whether the adaptation is valid. Here's a typical use, starting with a signature that takes two Strings and returns a String, dropping and inserting arguments, casting to a target signature, and finally calling a target handle with that signature.
MethodHandle mh = Binder
    .from(String.class, String.class, String.class) // String w(String, String)
    .drop(1, String.class) // String x(String)
    .insert(0, 'hello') // String y(String, String)
    .cast(String.class, CharSequence.class, Object.class) // String z(CharSequence, Object)String
    .invoke(someTargetHandle);

Field Summary

Modifier and TypeField and Description
private static final Logger
private final MethodHandles.Lookup
private final MethodType
private final List<Transform>
private final List<MethodType>

Constructor Summary

AccessConstructor and Description
public
Binder(MethodType
the starting MethodType, for calls entering the eventual chain
start
)

Construct a new Binder, starting from a given MethodType.

public
Binder(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
MethodType
the starting MethodType, for calls entering the eventual chain
start
)

Construct a new Binder, starting from a given Lookup and MethodType.

public
Binder(Binder
a Binder to duplicate
source
)

Construct a new Binder using the given invokebinder.

public
Binder(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
Binder
the source Binder
source
)

Construct a new Binder using the given Lookup and invokebinder.

public
Binder(Binder
the source Binder
source
,
Transform
the additional Transform
transform
)

Construct a new Binder using the given invokebinder plus an additional transform

public
Binder(Binder
the source Binder
source
,
Transform
the additional Transform
transform
,
MethodType
the new current type resulting from the transform
type
)

Construct a new Binder using the given invokebinder plus an additional transform and current type

Method Summary

Modifier and TypeMethod and Description
private void
add(Transform transform)

Add a Transform to the chain.

private void
add(Transform transform, MethodType target)

Add a Transform with an associated MethodType target to the chain.

public Binder

Returns:

a new Binder
append
(boolean
the value to append
value
)

Append to the argument list the given boolean value.

public Binder

Returns:

a new Binder
append
(byte
the value to append
value
)

Append to the argument list the given byte value.

public Binder

Returns:

a new Binder
append
(short
the value to append
value
)

Append to the argument list the given short value.

public Binder

Returns:

a new Binder
append
(char
the value to append
value
)

Append to the argument list the given char value.

public Binder

Returns:

a new Binder
append
(int
the value to append
value
)

Append to the argument list the given int value.

public Binder

Returns:

a new Binder
append
(long
the value to append
value
)

Append to the argument list the given long value.

public Binder

Returns:

a new Binder
append
(float
the value to append
value
)

Append to the argument list the given float value.

public Binder

Returns:

a new Binder
append
(double
the value to append
value
)

Append to the argument list the given double value.

public Binder

Returns:

a new Binder
append
(Object...
the value(s) to append
values
)

Append to the argument list the given argument value(s).

public Binder

Returns:

a new Binder
append
(Class<?>
the actual type to use, rather than getClass
type
,
Object
the value to append
value
)

Append to the argument list the given argument value with the specified type.

public Binder

Returns:

a new Binder
append
(Class<?>[]
the actual types to use, rather than getClass
types
,
Object...
the value(s) to append
values
)

Append to the argument list the given argument values with the specified types.

public Binder

Returns:

a new Binder
appendBooleans
(boolean...
the value to append
values
)

Append to the argument list the given boolean values.

public Binder

Returns:

a new Binder
appendBytes
(byte...
the values to append
values
)

Append to the argument list the given byte values.

public Binder

Returns:

a new Binder
appendChars
(char...
the values to append
values
)

Append to the argument list the given char values.

public Binder

Returns:

a new Binder
appendDoubles
(double...
the values to append
values
)

Append to the argument list the given double values.

public Binder

Returns:

a new Binder
appendFloats
(float...
the values to append
values
)

Append to the argument list the given float values.

public Binder

Returns:

a new Binder
appendInts
(int...
the values to append
values
)

Append to the argument list the given int values.

public Binder

Returns:

a new Binder
appendLongs
(long...
the values to append
values
)

Append to the argument list the given long values.

public Binder

Returns:

a new Binder
appendShorts
(short...
the values to append
values
)

Append to the argument list the given short values.

public Binder

Returns:

a new Binder
appendWithTypes
(Object...
the value(s) to append
typesAndValues
)

Append to the argument list the given argument type(s) and value(s), provided as (Class, value) pairs of arguments.

public MethodHandle
arrayAccess(VarHandle.AccessMode mode)

Apply the chain of transforms and bind them to an array varhandle operation.

public MethodHandle

Returns:

the full handle chain, bound to an array element get.
arrayGet
()

Apply the chain of transforms and bind them to an array element get.

public MethodHandle
arrayGetAcquire()

Apply the chain of transforms and bind them to an acquire-fenced array element get.

public MethodHandle
arrayGetOpaque()

Apply the chain of transforms and bind them to an opaque (no ordering guarantee) array element get.

public MethodHandle
arrayGetVolatile()

Apply the chain of transforms and bind them to a volatile array element get.

public MethodHandle

Returns:

a handle that gets the size of an array
arrayLength
()

Get the length of an array.

public MethodHandle

Returns:

the full handle chain, bound to an array element set.
arraySet
()

Apply the chain of transforms and bind them to an array element set.

public MethodHandle
arraySetAcquire()

Apply the chain of transforms and bind them to a release-fenced array element set.

public MethodHandle
arraySetOpaque()

Apply the chain of transforms and bind them to an opaque (no ordering guarantee) array element set.

public MethodHandle
arraySetVolatile()

Apply the chain of transforms and bind them to a volatile array element set.

public MethodHandle

Returns:

the full handle chain bound to a branch
branch
(MethodHandle
the test handle
test
,
MethodHandle
the target handle
truePath
,
MethodHandle
the fallback handle
falsePath
)

Apply the chain of transforms and bind them to a boolean branch as from java.lang.invoke.MethodHandles.guardWithTest.

public Binder

Returns:

a new Binder
cast
(MethodType
the target MethodType
type
)

Cast the incoming arguments to the given MethodType.

public Binder

Returns:

a new Binder
cast
(Class<?>
the target return type
returnType
,
Class<?>...
the target argument types
argTypes
)

Cast the incoming arguments to the given MethodType.

public Binder

Returns:

a new Binder
castVirtual
(Class<?>
the target return type
returnType
,
Class<?>
the first argument type, usually a target type
firstType
,
Class<?>...
the remaining target argument types
restTypes
)

Cast the incoming arguments to the given MethodType.

public Binder

Returns:

a new Binder
catchException
(Class<? extends Throwable>
the exception type to catch
throwable
,
MethodHandle
the function to use for handling the exception
function
)

Catch the given exception type from the downstream chain and handle it with the given function.

public Binder

Returns:

a new Binder
collect
(int
the index from which to start boxing args
index
,
Class<?>
the array type into which the args will be boxed
type
)

Box all incoming arguments from the given position onward into the given array type.

public Binder

Returns:

a new Binder
collect
(int
the index from which to start boxing args
index
,
Class<?>
the array type into which the args will be boxed
type
,
MethodHandle
a function to use for collecting the arguments
collector
)

Box all incoming arguments from the given position onward into the given array type.

public Binder

Returns:

a new Binder
collect
(int
the index from which to start boxing args
index
,
int
the count of arguments to box
count
,
Class<?>
the array type into which the args will be boxed
type
)

Box a range of incoming arguments into the given array type.

public Binder

Returns:

a new Binder
collect
(int
the index from which to start boxing args
index
,
int
the count of arguments to box
count
,
Class<?>
the array type into which the args will be boxed
type
,
MethodHandle
a function to use for collecting the arguments
collector
)

Box a range of incoming arguments into the given array type using the given constructor to construct the array.

public MethodHandle

Returns:

a handle that has all transforms applied in sequence up to the constant
constant
(Object
the constant value to put at the end of the chain
value
)

Apply the tranforms, binding them to a constant value that will propagate back through the chain.

public Binder

Returns:

a new Binder
convert
(MethodType
the target MethodType
target
)

Convert the incoming arguments to the given MethodType.

public Binder

Returns:

a new Binder
convert
(Class<?>
the target return type
returnType
,
Class<?>...
the target argument types
argTypes
)

Convert the incoming arguments to the given MethodType.

public Binder

Returns:

a new Binder
drop
(int
the index at which to drop an argument
index
)

Drop a single argument at the given index.

public Binder

Returns:

a new Binder
drop
(int
the index at which to start dropping
index
,
int
the number of arguments to drop
count
)

Drop from the given index a number of arguments.

public Binder

Returns:

a new Binder
dropAll
()

Drop all arguments from this handle chain

public Binder

Returns:

a new Binder
dropFirst
()

Drop a single argument at the beginning of the argument list.

public Binder

Returns:

a new Binder
dropFirst
(int
the number of arguments to drop
count
)

Drop from the end of the argument list a number of arguments.

public Binder

Returns:

a new Binder
dropLast
()

Drop a single argument at the end of the argument list.

public Binder

Returns:

a new Binder
dropLast
(int
the number of arguments to drop
count
)

Drop from the end of the argument list a number of arguments.

public Binder

Returns:

a new Binder
filter
(int
the index of the first argument to filter
index
,
MethodHandle...
the array of functions to transform the arguments
functions
)

Filter incoming arguments, from the given index, replacing each with the result of calling the associated function in the given list.

public Binder

Returns:

a new Binder
filterForward
(int
the index of the first argument to filter
index
,
MethodHandle...
the array of functions to transform the arguments
functions
)

Filter incoming arguments, from the given index, replacing each with the result of calling the associated function in the given list.

public Binder

Returns:

a new Binder
filterReturn
(MethodHandle
the array of functions to transform the arguments
function
)

Filter return value, using a function that produces the current return type from another type.

public Binder

Returns:

a new Binder
fold
(MethodHandle
the function that will process the incoming arguments. Its signature must match the current signature's arguments exactly.
function
)

Process the incoming arguments using the given handle, inserting the result as the first argument.

public Binder

Returns:

a new Binder
foldStatic
(MethodHandles.Lookup
the java.lang.invoke.MethodHandles.Lookup to use
lookup
,
Class<?>
the class on which the method is defined
target
,
String
the method to invoke on the first argument
method
)

Process the incoming arguments by calling the given static method on the given class, inserting the result as the first argument.

public Binder

Returns:

a new Binder
foldStatic
(Class<?>
the class on which the method is defined
target
,
String
the method to invoke on the first argument
method
)

Process the incoming arguments by calling the given static method on the given class, inserting the result as the first argument.

public Binder

Returns:

a new Binder
foldVirtual
(MethodHandles.Lookup
the java.lang.invoke.MethodHandles.Lookup to use
lookup
,
String
the method to invoke on the first argument
method
)

Process the incoming arguments by calling the given method on the first argument, inserting the result as the first argument.

public Binder

Returns:

a new Binder
foldVirtual
(String
the method to invoke on the first argument
method
)

Process the incoming arguments by calling the given method on the first argument, inserting the result as the first argument.

public Binder

Returns:

a new Binder
foldVoid
(MethodHandle
the function that will process the incoming arguments. Its signature must match the current signature's arguments exactly.
function
)

Process the incoming arguments using the given handle, leaving the argument list unmodified.

public static Binder

Returns:

the Binder object
from
(MethodType
the starting MethodType, for calls entering the eventual chain
start
)

Construct a new Binder, starting from a given MethodType.

public static Binder

Returns:

the Binder object
from
(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
MethodType
the starting MethodType, for calls entering the eventual chain
start
)

Construct a new Binder, starting from a given MethodType.

public static Binder

Returns:

the Binder object
from
(Class<?>
the return type of the incoming signature
returnType
)

Construct a new Binder using a return type.

public static Binder

Returns:

the Binder object
from
(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
Class<?>
the return type of the incoming signature
returnType
)

Construct a new Binder using a return type.

public static Binder

Returns:

the Binder object
from
(Class<?>
the return type of the incoming signature
returnType
,
Class<?>[]
the argument types of the incoming signature
argTypes
)

Construct a new Binder using a return type and argument types.

public static Binder

Returns:

the Binder object
from
(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
Class<?>
the return type of the incoming signature
returnType
,
Class<?>[]
the argument types of the incoming signature
argTypes
)

Construct a new Binder using a return type and argument types.

public static Binder

Returns:

the Binder object
from
(Class<?>
the return type of the incoming signature
returnType
,
Class<?>
the first argument type of the incoming signature
argType0
,
Class<?>...
the remaining argument types of the incoming signature
argTypes
)

Construct a new Binder using a return type and argument types.

public static Binder

Returns:

the Binder object
from
(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
Class<?>
the return type of the incoming signature
returnType
,
Class<?>
the first argument type of the incoming signature
argType0
,
Class<?>...
the remaining argument types of the incoming signature
argTypes
)

Construct a new Binder using a return type and argument types.

public static Binder

Returns:

the Binder object
from
(Binder
the starting invokebinder; the new one will start with the current endpoint type of the given invokebinder
start
)

Construct a new Binder, starting from a given invokebinder.

public static Binder

Returns:

the Binder object
from
(MethodHandles.Lookup
the Lookup context to use for direct handles
lookup
,
Binder
the starting invokebinder; the new one will start with the current endpoint type of the given invokebinder
start
)

Construct a new Binder, starting from a given invokebinder.

public MethodHandle

Returns:

the full handle chain, bound to the given field access
getField
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field retrieval specified using the end signature plus the given class and name.

public MethodHandle
getField(String name)

Same as getField(MethodHandles.Lookup, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field access
getFieldQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field retrieval specified using the end signature plus the given class and name.

public MethodHandle
getFieldQuiet(String name)

Same as getFieldQuiet(MethodHandles.Lookup, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field access
getStatic
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
Class<?>
the class in which the field is defined
target
,
String
the field's name
name
)

Apply the chain of transforms and bind them to a static field retrieval specified using the end signature plus the given class and name.

public MethodHandle
getStatic(Class<?> target, String name)

Same as getStatic(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field access
getStaticQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
Class<?>
the class in which the field is defined
target
,
String
the field's name
name
)

Apply the chain of transforms and bind them to a static field retrieval specified using the end signature plus the given class and name.

public MethodHandle
getStaticQuiet(Class<?> target, String name)

Same as getStaticQuiet(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public MethodHandle

Returns:

a handle that has all transforms applied in sequence
identity
()

Apply the tranforms, binding them to a handle that will simply return its sole argument as its return value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
boolean
the value to insert
value
)

Insert at the given index the given boolean value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
byte
the value to insert
value
)

Insert at the given index the given byte value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
short
the value to insert
value
)

Insert at the given index the given short value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
char
the value to insert
value
)

Insert at the given index the given char value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
int
the value to insert
value
)

Insert at the given index the given int value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
long
the value to insert
value
)

Insert at the given index the given long value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
float
the value to insert
value
)

Insert at the given index the given float value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
double
the value to insert
value
)

Insert at the given index the given double value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
Object...
the value(s) to insert
values
)

Insert at the given index the given argument value(s).

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
Class<?>
the actual type to use, rather than getClass
type
,
Object
the value to insert
value
)

Insert at the given index the given argument value.

public Binder

Returns:

a new Binder
insert
(int
the index at which to insert the argument value
index
,
Class<?>[]
the actual types to use, rather than getClass
types
,
Object...
the value(s) to insert
values
)

Insert at the given index the given argument value(s).

public MethodHandle

Returns:

a handle that has all transforms applied in sequence up to endpoint
invoke
(MethodHandle
the endpoint handle to bind to
target
)

Apply the chain of transforms with the target method handle as the final endpoint.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invoke
(MethodHandles.Lookup
the MethodHandles.Lookup to use to unreflect the method
lookup
,
Method
the Method to unreflect
method
)

Apply the chain of transforms and bind them to a static method specified using the end signature plus the given class and method.

public MethodHandle
invoke(Method method)

Same as invoke(MethodHandles.Lookup, Method method) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given constructor
invokeConstructor
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the constructor
lookup
,
Class<?>
the constructor's class
target
)

Apply the chain of transforms and bind them to a constructor specified using the end signature plus the given class.

public MethodHandle
invokeConstructor(Class<?> target)

Same as invokeConstructor(MethodHandles.Lookup, Class) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given constructor
invokeConstructorQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the constructor
lookup
,
Class<?>
the constructor's class
target
)

Apply the chain of transforms and bind them to a constructor specified using the end signature plus the given class.

public MethodHandle
invokeConstructorQuiet(Class<?> target)

Same as invokeConstructorQuiet(MethodHandles.Lookup, Class) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to unreflect the method
lookup
,
Method
the Method to unreflect
method
)

Apply the chain of transforms and bind them to a static method specified using the end signature plus the given class and method.

public MethodHandle
invokeQuiet(Method method)

Same as invokeQuiet(MethodHandles.Lookup, Method method) but using the default lookup for this binder.

public MethodHandle

Returns:

a new handle that invokes its leading MethodHandle argument
invoker
()

Produce a MethodHandle that invokes its leading MethodHandle argument with the remaining arguments, returning the result.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeSpecial
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the method
lookup
,
String
the name of the method to invoke
name
,
Class<?>
the calling class
caller
)

Apply the chain of transforms and bind them to a special method specified using the end signature plus the given class and name.

public MethodHandle
invokeSpecial(String name, Class<?> caller)

Same as invokeSpecial(MethodHandles.Lookup, String, Class) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeSpecialQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the method
lookup
,
String
the name of the method to invoke
name
,
Class<?>
the calling class
caller
)

Apply the chain of transforms and bind them to a special method specified using the end signature plus the given class and name.

public MethodHandle
invokeSpecialQuiet(String name, Class<?> caller)

Same as invokeSpecialQuiet(MethodHandles.Lookup, String, Class) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeStatic
(MethodHandles.Lookup
the MethodHandles.Lookup to use to unreflect the method
lookup
,
Class<?>
the class in which to find the method
target
,
String
the name of the method to invoke
name
)

Apply the chain of transforms and bind them to a static method specified using the end signature plus the given class and name.

public MethodHandle
invokeStatic(Class<?> target, String name)

Same as invokeStaticQuiet(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeStaticQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the method
lookup
,
Class<?>
the class in which to find the method
target
,
String
the name of the method to invoke
name
)

Apply the chain of transforms and bind them to a static method specified using the end signature plus the given class and name.

public MethodHandle
invokeStaticQuiet(Class<?> target, String name)

Same as invokeStaticQuiet(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeVirtual
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the method
lookup
,
String
the name of the method to invoke
name
)

Apply the chain of transforms and bind them to a virtual method specified using the end signature plus the given class and name.

public MethodHandle
invokeVirtual(String name)

Same as invokeVirtual(MethodHandles.Lookup, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given method
invokeVirtualQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the method
lookup
,
String
the name of the method to invoke
name
)

Apply the chain of transforms and bind them to a virtual method specified using the end signature plus the given class and name.

public MethodHandle
invokeVirtualQuiet(String name)

Same as invokeVirtualQuiet(MethodHandles.Lookup, String) but using the default lookup for this binder.

public Binder

Returns:

this Binding
logType
()

Log the current MethodType as info.

public MethodHandle

Returns:

a handle that constructs an array
newArray
()

Construct a new array.

public MethodHandle

Returns:

a handle that has all transforms applied and does nothing at its endpoint
nop
()

Apply all transforms to an endpoint that does absolutely nothing.

public Binder

Returns:

a new Binder
permute
(int...
the int offsets of the incoming arguments in the desired permutation
reorder
)

Permute the incoming arguments to a new sequence specified by the given values.

public Binder

Returns:

a new Binder
prepend
(boolean
the value to prepend
value
)

Prepend to the argument list the given boolean value.

public Binder

Returns:

a new Binder
prepend
(byte
the value to prepend
value
)

Prepend to the argument list the given byte value.

public Binder

Returns:

a new Binder
prepend
(short
the value to prepend
value
)

Prepend to the argument list the given short value.

public Binder

Returns:

a new Binder
prepend
(char
the value to prepend
value
)

Prepend to the argument list the given char value.

public Binder

Returns:

a new Binder
prepend
(int
the value to prepend
value
)

Prepend to the argument list the given int value.

public Binder

Returns:

a new Binder
prepend
(long
the value to prepend
value
)

Prepend to the argument list the given long value.

public Binder

Returns:

a new Binder
prepend
(float
the value to prepend
value
)

Prepend to the argument list the given float value.

public Binder

Returns:

a new Binder
prepend
(double
the value to prepend
value
)

Prepend to the argument list the given double value.

public Binder

Returns:

a new Binder
prepend
(Object...
the value(s) to prepend
values
)

Prepend to the argument list the given argument value(s).

public Binder

Returns:

a new Binder
prepend
(Class<?>
the actual type to use, rather than getClass
type
,
Object
the value(s) to prepend
value
)

Prepend to the argument list the given argument value with the specified type

public Binder

Returns:

a new Binder
prepend
(Class<?>[]
the actual types to use, rather than getClass
types
,
Object...
the value(s) to prepend
values
)

Prepend to the argument list the given argument values with the specified types.

public Binder

Returns:

a new Binder
prependBooleans
(boolean...
the values to prepend
values
)

Prepend to the argument list the given boolean values.

public Binder

Returns:

a new Binder
prependBytes
(byte...
the values to prepend
values
)

Prepend to the argument list the given byte values.

public Binder

Returns:

a new Binder
prependChars
(char...
the values to prepend
values
)

Prepend to the argument list the given char values.

public Binder

Returns:

a new Binder
prependDoubles
(double...
the values to prepend
values
)

Prepend to the argument list the given double values.

public Binder

Returns:

a new Binder
prependFloats
(float...
the values to prepend
values
)

Prepend to the argument list the given float values.

public Binder

Returns:

a new Binder
prependInts
(int...
the values to prepend
values
)

Prepend to the argument list the given int values.

public Binder

Returns:

a new Binder
prependLongs
(long...
the values to prepend
values
)

Prepend to the argument list the given long values.

public Binder

Returns:

a new Binder
prependShorts
(short...
the values to prepend
values
)

Prepend to the argument list the given short values.

public Binder

Returns:

a new Binder
prependWithTypes
(Object...
the value(s) to append
typesAndValues
)

Prepend to the argument list the given argument type(s) and value(s), provided as (Class, value) pairs of arguments.

public Binder

Returns:

this Binding
printType
(PrintStream
a PrintStream to which to println the current MethodType
ps
)

Println the current MethodType to the given stream.

public Binder

Returns:

this Binding
printType
()

Println the current MethodType to stdout.

public MethodHandle

Returns:

the full handle chain, bound to the given field assignment
setField
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field assignment specified using the end signature plus the given class and name.

public MethodHandle
setField(String name)

Same as setField(MethodHandles.Lookup, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field assignment
setFieldQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field assignment specified using the end signature plus the given class and name.

public MethodHandle
setFieldQuiet(String name)

Same as setFieldQuiet(MethodHandles.Lookup, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field assignment
setStatic
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
Class<?>
the class in which the field is defined
target
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field assignment specified using the end signature plus the given class and name.

public MethodHandle
setStatic(Class<?> target, String name)

Same as setStatic(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public MethodHandle

Returns:

the full handle chain, bound to the given field assignment
setStaticQuiet
(MethodHandles.Lookup
the MethodHandles.Lookup to use to look up the field
lookup
,
Class<?>
the class in which the field is defined
target
,
String
the field's name
name
)

Apply the chain of transforms and bind them to an object field assignment specified using the end signature plus the given class and name.

public MethodHandle
setStaticQuiet(Class<?> target, String name)

Same as setStaticQuiet(MethodHandles.Lookup, Class, String) but using the default lookup for this binder.

public Binder

Returns:

a new Binder
spread
(Class<?>...
the types into which to spread the incoming Object[]
spreadTypes
)

Spread a trailing array argument into the specified argument types.

public Binder

Returns:

a new Binder
spread
(int
the new count of arguments to spread from the trailing array
count
)

Spread a trailing array argument into the given number of arguments of the type of the array.

public MethodHandle

Returns:

a handle that has all transforms applied and which will eventually throw an exception
throwException
()

Throw the current signature's sole Throwable argument.

public Binder

Returns:

a new Binder combining this Binder with the target Binder
to
(Binder
the Binder containing the set of transformations to append
other
)

Join this binder to an existing one by applying its transformations after this one.

public String

Returns:

Java code for the handle adaptations this Binder would produce.
toJava
(MethodType incoming)

Produce Java code that would perform equivalent operations to this binder.

public Binder

Returns:

a new Binder
tryFinally
(MethodHandle
the logic that would live inside the "finally" block
post
)

Apply transforms to run the given handle's logic as a "finally" block.

public MethodType

Returns:

the current MethodType
type
()

The current MethodType, were the handle chain to terminate at this point.

public Binder

Returns:

a new Binder
varargs
(int
the index from which to start boxing args
index
,
Class<?>
the array type into which the args will be boxed
type
)

Box all incoming arguments from the given position onward into the given array type.

public Binder

Returns:

a new Binder with the given lookup
withLookup
(MethodHandles.Lookup
the new Lookup context to use
lookup
)

Use an alternate java.lang.invoke.MethodHandles.Lookup as the default for any direct handles created.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait