Top Description Fields Constructors Methods
com.headius.invokebinder

public Class SmartBinder

extends Object
Class Inheritance
Imports
java.io.PrintStream, java.lang.invoke.MethodHandle, .MethodHandles.Lookup, java.lang.reflect.Array, java.util.ArrayList, .Arrays, .List, java.util.regex.Pattern

Maintains both a Binder, for building a series of transformations, and a current Signature that maps symbolic names to arguments. Transformations normally performed with Binder using argument indices can be done instead using argument names and wildcards.

Todo

Examples, or links to wiki examples.

Author
headius

Field Summary

Modifier and TypeField and Description
private final Binder
private final List<Signature>
private final Signature

Constructor Summary

AccessConstructor and Description
private
SmartBinder(Signature start, Binder binder)

private
SmartBinder(SmartBinder original, Signature next, Binder binder)

Method Summary

Modifier and TypeMethod and Description
public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
Object
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
boolean
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
byte
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
short
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
char
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
int
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
long
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
float
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
double
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String
the name of the new argument
name
,
Class<?>
the type to use in the new signature
type
,
Object
the value of the new argument
value
)

Append the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the append applied
append
(String[]
the names of the new arguments
names
,
Class<?>[]
the types to use in the new signature
types
,
Object...
the values of the new arguments
values
)

Append the given arguments to the argument list, assigning them the given names.

public SmartHandle

Returns:

a new SmartHandle with this binder's starting signature, bound to an array assignment operation
arrayGet
()

Terminate this binder by setting an array element based on the current signature.

public SmartHandle

Returns:

a new SmartHandle with this binder's starting signature, bound to an array dereference operation
arraySet
()

Terminate this binder by getting an array element based on the current signature.

public Signature

Returns:

the signature this binder started with.
baseSignature
()

Get the signature this binder started with.

public Binder

Returns:

this SmartBinder's Binder instance
binder
()

Get the Binder instance associated with this SmartBinder.

public SmartBinder

Returns:

a new SmartBinder with the cast applied
cast
(Signature
the Signature to which arguments should be cast
target
)

Cast the incoming arguments to the types in the given signature.

public SmartBinder

Returns:

a new SmartBinder with the cast applied
cast
(Class<?>
the return type for the casted signature
returnType
,
Class<?>...
the types of the arguments for the casted signature
argTypes
)

Cast the incoming arguments to the return and argument types given.

public SmartBinder

Returns:

a new SmartBinder with the cast applied
castArg
(String
the name of the argument to cast
name
,
Class<?>
the type to which that argument will be cast
type
)

Cast the named argument to the given type.

public SmartBinder

Returns:

a new SmartBinder
castReturn
(Class<?>
the new type for the return value
type
)

Cast the return value to the given type.

public SmartBinder

Returns:

a new SmartBinder with the cast applied.
castVirtual
(Class<?>
the return type for the casted signature
returnType
,
Class<?>
the type of the first argument for the casted signature
firstArg
,
Class<?>...
the types of the remaining arguments for the casted signature
restArgs
)

Cast the incoming arguments to the return, first argument type, and remaining argument types.

public SmartBinder

Returns:

a new SmartBinder with the collect applied
collect
(String
the name of the new array argument
outName
,
String
a pattern with which to match arguments for collecting
namePattern
)

Collect arguments matching namePattern into an trailing array argument named outName.

public SmartBinder

Returns:

a new SmartBinder with the collect applied
collect
(String
the name of the new array argument
outName
,
String
a pattern with which to match arguments for collecting
namePattern
,
MethodHandle
a function to use for collecting the arguments
collector
)

Collect arguments matching namePattern into an trailing array argument named outName, using collector to construct the array object.

public SmartBinder

Returns:

a new SmartBinder with the drop applied
drop
(String
the name of the argument to drop
name
)

Drop the argument with the given name.

public SmartBinder

Returns:

a new SmartBinder with the drop applied
dropFirst
()

Drop the first argument.

public SmartBinder

Returns:

a new SmartBinder with the drop applied
dropFirst
(int
the count of arguments to drop
count
)

Drop the first N arguments.

public SmartBinder

Returns:

a new SmartBinder with the drop applied
dropLast
()

Drop the last argument.

public SmartBinder

Returns:

a new SmartBinder with the drop applied
dropLast
(int
the count of arguments to drop
count
)

Drop the last N arguments.

public SmartBinder

Returns:

a new SmartBinder with the exclude applied
exclude
(String...
parameter patterns to exclude
excludeNames
)

Permute all parameters except the names given.

public SmartBinder

Returns:

a new SmartBinder with the filter applied
filter
(String
the regular expression pattern to match arguments
pattern
,
MethodHandle
the MethodHandle to use to filter the arguments
filter
)

Filter the arguments matching the given pattern using the given filter function.

public SmartBinder

Returns:

a new SmartBinder with the filter applied
filterReturn
(MethodHandle
the function to use to transform the return value at this point
filter
)

Use the given filter function to transform the return value at this point in the binder.

public SmartBinder

Returns:

a new SmartBinder with the filter applied
filterReturn
(SmartHandle
the function to use to transform the return value at this point
filter
)

Use the given filter function to transform the return value at this point in the binder.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
fold
(String
the name of the new first argument where the fold function's result will be passed
newName
,
MethodHandle
a function which will receive all arguments and have its return value inserted into the call chain
function
)

Pass all arguments to the given function and insert the resulting value as newName into the argument list.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
fold
(String
the name of the new first argument where the fold function's result will be passed
newName
,
SmartHandle
a function which will receive all arguments and have its return value inserted into the call chain
function
)

Pass all arguments to the given function and insert the resulting value as newName into the argument list.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldStatic
(String
the name of the new first argument where the fold function's result will be passed
newName
,
MethodHandles.Lookup
the Lookup to use for acquiring a folding function
lookup
,
Class<?>
the class on which to find the folding function
target
,
String
the name of the method to become a folding function
method
)

Acquire a static folding function from the given target class, using the given name and Lookup.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldStatic
(String
the name of the new first argument where the fold function's result will be passed
newName
,
Class<?>
the class on which to find the folding function
target
,
String
the name of the method to become a folding function
method
)

Acquire a public static folding function from the given target class, using the given name.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldVirtual
(String
the name of the new first argument where the fold function's result will be passed
newName
,
MethodHandles.Lookup
the Lookup to use for acquiring a folding function
lookup
,
String
the name of the method to become a folding function
method
)

Acquire a virtual folding function from the first argument's class, using the given name and Lookup.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldVirtual
(String
the name of the new first argument where the fold function's result will be passed
newName
,
String
the name of the method to become a folding function
method
)

Acquire a public virtual folding function from the first argument's class, using the given name and Lookup.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldVoid
(MethodHandle
a function which will receive all arguments and have its return value inserted into the call chain
function
)

Pass all arguments to the given function and drop any result.

public SmartBinder

Returns:

a new SmartBinder with the fold applied
foldVoid
(SmartHandle
a function which will receive all arguments and have its return value inserted into the call chain
function
)

Pass all arguments to the given function and drop any result.

public static SmartBinder

Returns:

a new SmartBinder
from
(Signature
the Signature to start from
inbound
)

Create a new SmartBinder from the given Signature.

public static SmartBinder

Returns:

a new SmartBinder
from
(Class<?>
the type of the return value to start with
retType
,
String[]
the names of arguments
names
,
Class<?>...
the argument types
types
)

Create a new SmartBinder from the given types and argument names.

public static SmartBinder

Returns:

a new SmartBinder
from
(Class<?>
the type of the return value to start with
retType
,
String
the name of the sole argument
name
,
Class<?>
the sole argument's type
type
)

Create a new SmartBinder with from the given types and argument name.

public static SmartBinder

Returns:

a new SmartBinder
from
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
Signature
the Signature to start from
inbound
)

Create a new SmartBinder from the given Signature, using the given Lookup for any handle lookups.

public static SmartBinder

Returns:

a new SmartBinder
from
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
Class<?>
the type of the return value to start with
retType
,
String[]
the names of arguments
names
,
Class<?>...
the argument types
types
)

Create a new SmartBinder from the given types and argument names, using the given Lookup for any handle lookups.

public static SmartBinder

Returns:

a new SmartBinder
from
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
Class<?>
the type of the return value to start with
retType
,
String
the name of the sole arguments
name
,
Class<?>
the sole argument's type
type
)

Create a new SmartBinder from the given types and argument name, using the given Lookup for any handle lookups.

public SmartHandle

Returns:

a new SmartHandle with this binder's starting signature that simply returns its sole received argument
identity
()

Terminate this binder by returning its sole remaining argument.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
Object
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
boolean
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
byte
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
short
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
char
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
int
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
long
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
float
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
double
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the argument
index
,
String
the name of the new argument
name
,
Class<?>
the type to use in the new signature
type
,
Object
the value of the new argument
value
)

Insert an argument into the argument list at the given index with the given name and value.

public SmartBinder

Returns:

a new SmartBinder with the insert applied
insert
(int
the index at which to insert the arguments
index
,
String[]
the names of the new arguments
names
,
Class<?>[]
the types of the new arguments
types
,
Object...
the values of the new arguments
values
)

Insert arguments into the argument list at the given index with the given names and values.

public SmartHandle

Returns:

a new SmartHandle with this binder's starting signature, bound through to the given handle
invoke
(SmartHandle
the handle to invoke
target
)

Terminate this binder by invoking the given target handle.

public SmartHandle

Returns:

a new SmartHandle with this binder's starting signature, bound through to the given handle
invoke
(MethodHandle
the handle to invoke
target
)

Terminate this binder by invoking the given target handle.

public SmartHandle

Returns:

a SmartHandle that invokes its leading MethodHandle argument
invoker
()

Produce a SmartHandle from this binder that invokes a leading MethodHandle argument with the remaining arguments.

public SmartHandle

Returns:

a SmartHandle with this binder's starting signature, bound to the target method
invokeStatic
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
Class<?>
the type on which to find the static method
target
,
String
the name of the target static method
name
)

Terminate this binder by looking up the named static method on the given target type.

public SmartHandle

Returns:

a SmartHandle with this binder's starting signature, bound to the target method
invokeStaticQuiet
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
Class<?>
the type on which to find the static method
target
,
String
the name of the target static method
name
)

Terminate this binder by looking up the named static method on the given target type.

public SmartHandle

Returns:

a SmartHandle with this binder's starting signature, bound to the target method
invokeVirtual
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
String
the name of the target virtual method
name
)

Terminate this binder by looking up the named virtual method on the first argument's type.

public SmartHandle

Returns:

a SmartHandle with this binder's starting signature, bound to the target method
invokeVirtualQuiet
(MethodHandles.Lookup
the Lookup to use for handle lookups
lookup
,
String
the name of the target virtual method
name
)

Terminate this binder by looking up the named virtual method on the first argument's type.

public SmartBinder

Returns:

a new SmartBinder with the permute applied
permute
(Signature
the Signature from which to derive a new argument list
target
)

Using the argument names and order in the target Signature, permute the arguments in this SmartBinder.

public SmartBinder

Returns:

a new SmartBinder with the permute applied
permute
(String...
the array of names from which to derive a new argument list
targetNames
)

Using the argument names and order in the given targetNames, permute the arguments in this SmartBinder.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
Object
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
boolean
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
byte
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
short
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
char
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
int
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
long
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
float
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
double
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String
the name of the new argument
name
,
Class<?>
the type to use in the new signature
type
,
Object
the value of the new argument
value
)

Prepend the given argument to the argument list, assigning it the given name.

public SmartBinder

Returns:

a new SmartBinder with the prepend applied
prepend
(String[]
the names of the new arguments
names
,
Class<?>[]
the types to use in the new signature
types
,
Object...
the values of the new arguments
values
)

Prepend the given arguments to the argument list, assigning them the given name.

public SmartBinder

Returns:

this SmartBinder
printSignature
()

Print this binder's current signature to System.out.

public SmartBinder

Returns:

this SmartBinder
printSignature
(PrintStream ps)

Print this binder's current signature to the give PrintStream.

public Signature

Returns:

this binder's current Signature
signature
()

Get the current Signature for this binder.

public SmartBinder

Returns:

a new SmartBinder with the spread applied
spread
(String[]
the names for the spread out arguments
spreadNames
,
Class<?>...
the types as which to spread the incoming array
spreadTypes
)

Spread a trailing array into the specified argument types.

public SmartBinder

Returns:

a new SmartBinder with the spread applied
spread
(String
the base name from which to create the new argument names
baseName
,
int
the count of arguments to spread
count
)

Spread a trailing array into count number of arguments, using the natural component type for the array.

public SmartBinder
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait