public class SmartBinder extends Object
| Modifier and Type | Method | Description |
|---|---|---|
SmartBinder |
append(String[] names,
Class<?>[] types,
Object... values) |
Append the given arguments to the argument list, assigning them the
given names.
|
SmartBinder |
append(String name,
boolean value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
byte value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
char value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
double value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
float value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
int value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
long value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
short value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
Class<?> type,
Object value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
append(String name,
Object value) |
Append the given argument to the argument list, assigning it the
given name.
|
SmartHandle |
arrayGet() |
Terminate this binder by setting an array element based on the current
signature.
|
SmartHandle |
arraySet() |
Terminate this binder by getting an array element based on the current
signature.
|
Signature |
baseSignature() |
Get the signature this binder started with.
|
Binder |
binder() |
Get the Binder instance associated with this SmartBinder.
|
SmartBinder |
cast(Signature target) |
Cast the incoming arguments to the types in the given signature.
|
SmartBinder |
cast(Class<?> returnType,
Class<?>... argTypes) |
Cast the incoming arguments to the return and argument types given.
|
SmartBinder |
castArg(String name,
Class<?> type) |
Cast the named argument to the given type.
|
SmartBinder |
castReturn(Class<?> type) |
Cast the return value to the given type.
|
SmartBinder |
castVirtual(Class<?> returnType,
Class<?> firstArg,
Class<?>... restArgs) |
Cast the incoming arguments to the return, first argument type, and
remaining argument types.
|
SmartBinder |
collect(String outName,
String namePattern) |
Collect arguments matching namePattern into an trailing array argument
named outName.
|
SmartBinder |
drop(String name) |
Drop the argument with the given name.
|
SmartBinder |
dropFirst() |
Drop the first argument.
|
SmartBinder |
dropFirst(int count) |
Drop the first N arguments.
|
SmartBinder |
dropLast() |
Drop the last argument.
|
SmartBinder |
dropLast(int count) |
Drop the last N arguments.
|
SmartBinder |
exclude(String... excludeNames) |
Permute all parameters except the names given.
|
SmartBinder |
filter(String pattern,
MethodHandle filter) |
Filter the arguments matching the given pattern using the given filter function.
|
SmartBinder |
filterReturn(SmartHandle filter) |
Use the given filter function to transform the return value at this
point in the binder.
|
SmartBinder |
filterReturn(MethodHandle filter) |
Use the given filter function to transform the return value at this
point in the binder.
|
SmartBinder |
fold(String newName,
SmartHandle function) |
Pass all arguments to the given function and insert the resulting value
as newName into the argument list.
|
SmartBinder |
fold(String newName,
MethodHandle function) |
Pass all arguments to the given function and insert the resulting value
as newName into the argument list.
|
SmartBinder |
foldStatic(String newName,
Class<?> target,
String method) |
Acquire a public static folding function from the given target class,
using the given name.
|
SmartBinder |
foldStatic(String newName,
MethodHandles.Lookup lookup,
Class<?> target,
String method) |
Acquire a static folding function from the given target class, using the
given name and Lookup.
|
SmartBinder |
foldVirtual(String newName,
MethodHandles.Lookup lookup,
String method) |
Acquire a virtual folding function from the first argument's class,
using the given name and Lookup.
|
SmartBinder |
foldVirtual(String newName,
String method) |
Acquire a public virtual folding function from the first argument's
class, using the given name and Lookup.
|
SmartBinder |
foldVoid(SmartHandle function) |
Pass all arguments to the given function and drop any result.
|
SmartBinder |
foldVoid(MethodHandle function) |
Pass all arguments to the given function and drop any result.
|
static SmartBinder |
from(Signature inbound) |
Create a new SmartBinder from the given Signature.
|
static SmartBinder |
from(Class<?> retType,
String[] names,
Class<?>... types) |
Create a new SmartBinder from the given types and argument names.
|
static SmartBinder |
from(Class<?> retType,
String name,
Class<?> type) |
Create a new SmartBinder with from the given types and argument name.
|
static SmartBinder |
from(MethodHandles.Lookup lookup,
Signature inbound) |
Create a new SmartBinder from the given Signature, using the given
Lookup for any handle lookups.
|
static SmartBinder |
from(MethodHandles.Lookup lookup,
Class<?> retType,
String[] names,
Class<?>... types) |
Create a new SmartBinder from the given types and argument names,
using the given Lookup for any handle lookups.
|
static SmartBinder |
from(MethodHandles.Lookup lookup,
Class<?> retType,
String name,
Class<?> type) |
Create a new SmartBinder from the given types and argument name,
using the given Lookup for any handle lookups.
|
SmartHandle |
identity() |
Terminate this binder by returning its sole remaining argument.
|
SmartBinder |
insert(int index,
String[] names,
Class<?>[] types,
Object... values) |
Insert arguments into the argument list at the given index with the
given names and values.
|
SmartBinder |
insert(int index,
String name,
boolean value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
byte value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
char value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
double value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
float value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
int value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
long value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
short value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
Class<?> type,
Object value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartBinder |
insert(int index,
String name,
Object value) |
Insert an argument into the argument list at the given index with the
given name and value.
|
SmartHandle |
invoke(SmartHandle target) |
Terminate this binder by invoking the given target handle.
|
SmartHandle |
invoke(MethodHandle target) |
Terminate this binder by invoking the given target handle.
|
SmartHandle |
invoker() |
Produce a SmartHandle from this binder that invokes a leading
MethodHandle argument with the remaining arguments.
|
SmartHandle |
invokeStatic(MethodHandles.Lookup lookup,
Class<?> target,
String name) |
Terminate this binder by looking up the named static method on the
given target type.
|
SmartHandle |
invokeStaticQuiet(MethodHandles.Lookup lookup,
Class<?> target,
String name) |
Terminate this binder by looking up the named static method on the
given target type.
|
SmartHandle |
invokeVirtual(MethodHandles.Lookup lookup,
String name) |
Terminate this binder by looking up the named virtual method on the
first argument's type.
|
SmartHandle |
invokeVirtualQuiet(MethodHandles.Lookup lookup,
String name) |
Terminate this binder by looking up the named virtual method on the
first argument's type.
|
SmartBinder |
permute(Signature target) |
Using the argument names and order in the target Signature, permute the
arguments in this SmartBinder.
|
SmartBinder |
permute(String... targetNames) |
Using the argument names and order in the given targetNames, permute the
arguments in this SmartBinder.
|
SmartBinder |
prepend(String[] names,
Class<?>[] types,
Object... values) |
Prepend the given arguments to the argument list, assigning them the
given name.
|
SmartBinder |
prepend(String name,
boolean value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
byte value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
char value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
double value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
float value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
int value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
long value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
short value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
Class<?> type,
Object value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
prepend(String name,
Object value) |
Prepend the given argument to the argument list, assigning it the
given name.
|
SmartBinder |
printSignature() |
Print this binder's current signature to System.out.
|
SmartBinder |
printSignature(PrintStream ps) |
Print this binder's current signature to the give PrintStream.
|
Signature |
signature() |
Get the current Signature for this binder.
|
SmartBinder |
spread(String[] spreadNames,
Class<?>... spreadTypes) |
Spread a trailing array into the specified argument types.
|
SmartBinder |
spread(String baseName,
int count) |
Spread a trailing array into count number of arguments, using the
natural component type for the array.
|
SmartBinder |
tryFinally(MethodHandle post) |
public Signature signature()
public Signature baseSignature()
public Binder binder()
public static SmartBinder from(Signature inbound)
inbound - the Signature to start frompublic static SmartBinder from(Class<?> retType, String[] names, Class<?>... types)
retType - the type of the return value to start withnames - the names of argumentstypes - the argument typespublic static SmartBinder from(Class<?> retType, String name, Class<?> type)
retType - the type of the return value to start withname - the name of the sole argumenttype - the sole argument's typepublic static SmartBinder from(MethodHandles.Lookup lookup, Signature inbound)
lookup - the Lookup to use for handle lookupsinbound - the Signature to start frompublic static SmartBinder from(MethodHandles.Lookup lookup, Class<?> retType, String[] names, Class<?>... types)
lookup - the Lookup to use for handle lookupsretType - the type of the return value to start withnames - the names of argumentstypes - the argument typespublic static SmartBinder from(MethodHandles.Lookup lookup, Class<?> retType, String name, Class<?> type)
lookup - the Lookup to use for handle lookupsretType - the type of the return value to start withname - the name of the sole argumentstype - the sole argument's typepublic SmartBinder fold(String newName, MethodHandle function)
newName - the name of the new first argument where the fold
function's result will be passedfunction - a function which will receive all arguments and have its
return value inserted into the call chainpublic SmartBinder fold(String newName, SmartHandle function)
newName - the name of the new first argument where the fold
function's result will be passedfunction - a function which will receive all arguments and have its
return value inserted into the call chainpublic SmartBinder foldVoid(MethodHandle function)
function - a function which will receive all arguments and have its
return value inserted into the call chainpublic SmartBinder foldVoid(SmartHandle function)
function - a function which will receive all arguments and have its
return value inserted into the call chainpublic SmartBinder foldStatic(String newName, MethodHandles.Lookup lookup, Class<?> target, String method)
newName - the name of the new first argument where the fold
function's result will be passedlookup - the Lookup to use for acquiring a folding functiontarget - the class on which to find the folding functionmethod - the name of the method to become a folding functionpublic SmartBinder foldStatic(String newName, Class<?> target, String method)
newName - the name of the new first argument where the fold
function's result will be passedtarget - the class on which to find the folding functionmethod - the name of the method to become a folding functionpublic SmartBinder foldVirtual(String newName, MethodHandles.Lookup lookup, String method)
newName - the name of the new first argument where the fold
function's result will be passedlookup - the Lookup to use for acquiring a folding functionmethod - the name of the method to become a folding functionpublic SmartBinder foldVirtual(String newName, String method)
newName - the name of the new first argument where the fold
function's result will be passedmethod - the name of the method to become a folding functionpublic SmartBinder permute(Signature target)
target - the Signature from which to derive a new argument listpublic SmartBinder permute(String... targetNames)
targetNames - the array of names from which to derive a new argument
listpublic SmartBinder exclude(String... excludeNames)
excludeNames - parameter patterns to excludepublic SmartBinder spread(String[] spreadNames, Class<?>... spreadTypes)
spreadNames - the names for the spread out argumentsspreadTypes - the types as which to spread the incoming arraypublic SmartBinder spread(String baseName, int count)
binder = binder.spread("str", 5)
The resulting signature will have five trailing arguments named
"arg0" through "arg4".baseName - the base name from which to create the new argument namescount - the count of arguments to spreadpublic SmartBinder insert(int index, String name, Object value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, boolean value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, byte value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, short value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, char value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, int value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, long value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, float value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, double value)
index - the index at which to insert the argumentname - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder insert(int index, String name, Class<?> type, Object value)
index - the index at which to insert the argumentname - the name of the new argumenttype - the type to use in the new signaturevalue - the value of the new argumentpublic SmartBinder insert(int index, String[] names, Class<?>[] types, Object... values)
index - the index at which to insert the argumentsnames - the names of the new argumentstypes - the types of the new argumentsvalues - the values of the new argumentspublic SmartBinder append(String name, Object value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, boolean value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, byte value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, short value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, char value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, int value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, long value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, float value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, double value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder append(String name, Class<?> type, Object value)
name - the name of the new argumenttype - the type to use in the new signaturevalue - the value of the new argumentpublic SmartBinder append(String[] names, Class<?>[] types, Object... values)
names - the names of the new argumentstypes - the types to use in the new signaturevalues - the values of the new argumentspublic SmartBinder prepend(String name, Object value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, boolean value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, byte value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, short value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, char value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, int value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, long value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, float value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, double value)
name - the name of the new argumentvalue - the value of the new argumentpublic SmartBinder prepend(String name, Class<?> type, Object value)
name - the name of the new argumenttype - the type to use in the new signaturevalue - the value of the new argumentpublic SmartBinder prepend(String[] names, Class<?>[] types, Object... values)
names - the names of the new argumentstypes - the types to use in the new signaturevalues - the values of the new argumentspublic SmartBinder drop(String name)
name - the name of the argument to droppublic SmartBinder dropLast()
public SmartBinder dropLast(int count)
count - the count of arguments to droppublic SmartBinder dropFirst()
public SmartBinder dropFirst(int count)
count - the count of arguments to droppublic SmartBinder collect(String outName, String namePattern)
outName - the name of the new array argumentnamePattern - a pattern with which to match arguments for collectingpublic SmartBinder cast(Signature target)
target - the Signature to which arguments should be castpublic SmartBinder cast(Class<?> returnType, Class<?>... argTypes)
returnType - the return type for the casted signatureargTypes - the types of the arguments for the casted signaturepublic SmartBinder castVirtual(Class<?> returnType, Class<?> firstArg, Class<?>... restArgs)
returnType - the return type for the casted signaturefirstArg - the type of the first argument for the casted signaturerestArgs - the types of the remaining arguments for the casted signaturepublic SmartBinder castArg(String name, Class<?> type)
name - the name of the argument to casttype - the type to which that argument will be castpublic SmartBinder castReturn(Class<?> type)
binder = binder.castReturn(CharSequence.class);
Our handle will now successfully find and call the target method and
propagate the returned CharSequence as a String.type - the new type for the return valuepublic SmartBinder filterReturn(MethodHandle filter)
filter - the function to use to transform the return value at this pointpublic SmartBinder filterReturn(SmartHandle filter)
filter - the function to use to transform the return value at this pointpublic SmartHandle invokeVirtual(MethodHandles.Lookup lookup, String name) throws NoSuchMethodException, IllegalAccessException
lookup - the Lookup to use for handle lookupsname - the name of the target virtual methodNoSuchMethodException - if the named method with current signature's types does not existIllegalAccessException - if the named method is not accessible to the given Lookuppublic SmartHandle invokeVirtualQuiet(MethodHandles.Lookup lookup, String name)
lookup - the Lookup to use for handle lookupsname - the name of the target virtual methodpublic SmartHandle invokeStatic(MethodHandles.Lookup lookup, Class<?> target, String name) throws NoSuchMethodException, IllegalAccessException
lookup - the Lookup to use for handle lookupstarget - the type on which to find the static methodname - the name of the target static methodNoSuchMethodException - if the named method with current signature's types does not existIllegalAccessException - if the named method is not accessible to the given Lookuppublic SmartHandle invokeStaticQuiet(MethodHandles.Lookup lookup, Class<?> target, String name)
lookup - the Lookup to use for handle lookupstarget - the type on which to find the static methodname - the name of the target static methodpublic SmartHandle invoke(SmartHandle target)
target - the handle to invokepublic SmartHandle invoke(MethodHandle target)
target - the handle to invokepublic SmartHandle arrayGet()
public SmartHandle arraySet()
public SmartHandle identity()
public SmartBinder printSignature()
public SmartBinder printSignature(PrintStream ps)
public SmartHandle invoker()
public SmartBinder filter(String pattern, MethodHandle filter)
pattern - the regular expression pattern to match argumentsfilter - the MethodHandle to use to filter the argumentspublic SmartBinder tryFinally(MethodHandle post)
Binder.tryFinally(MethodHandle)Copyright © 2018. All rights reserved.