public class Signature extends Object
Modifier and Type | Method and Description |
---|---|
Signature |
appendArg(String name,
Class type)
Append an argument (name + type) to the signature.
|
Signature |
appendArgs(String[] names,
Class... types)
Append an argument (name + type) to the signature.
|
String |
argName(int index)
Retrieve the name of the argument at the given index.
|
String[] |
argNames()
The current argument names for this signature.
|
int |
argOffset(String name)
Retrieve the offset of the given argument name in this signature's
arguments.
|
int |
argOffsets(String pattern)
Retrieve the offset of the given argument name in this signature's
arguments.
|
Class |
argType(int index)
Get the argument type at the given index.
|
Signature |
asFold(Class retval)
Produce a new signature based on this one with a different return type.
|
Signature |
changeReturn(Class retval)
Create a new signature based on this one with a different return type.
|
Signature |
dropArg(int index)
Drops the argument at the given index.
|
Signature |
dropArg(String name)
Drops the first argument with the given name.
|
Signature |
dropFirst()
Drop the first argument from this signature.
|
Signature |
dropLast()
Drop the last argument from this signature.
|
Signature |
exclude(String... excludeArgs)
Create a new signature containing the same return value as this one, but
omitting the specified arguments.
|
String |
firstArgName()
Get the first argument name.
|
Class |
firstArgType()
Get the first argument type.
|
Signature |
insertArg(int index,
String name,
Class type)
Insert an argument (name + type) into the signature.
|
Signature |
insertArg(String beforeName,
String name,
Class type)
Insert an argument (name + type) into the signature before the argument
with the given name.
|
Signature |
insertArgs(int index,
String[] names,
Class... types)
Insert arguments (names + types) into the signature.
|
Signature |
insertArgs(String beforeName,
String[] names,
Class... types)
Insert arguments (names + types) into the signature before the argument
with the given name.
|
String |
lastArgName()
Get the last argument name.
|
Class |
lastArgType()
Get the last argument type.
|
Signature |
permute(String... permuteArgs)
Create a new signature containing the same return value as this one, but
only the specified arguments.
|
MethodHandle |
permuteWith(MethodHandle target,
String... permuteArgs)
Produce a method handle permuting the arguments in this signature using
the given permute arguments and targeting the given java.lang.invoke.MethodHandle.
|
SmartHandle |
permuteWith(SmartHandle target)
Produce a new SmartHandle by permuting this Signature's arguments to the
Signature of a target SmartHandle.
|
Signature |
prependArg(String name,
Class type)
Prepend an argument (name + type) to the signature.
|
Signature |
prependArgs(String[] names,
Class[] types)
Prepend an argument (name + type) to the signature.
|
Signature |
replaceArg(String oldName,
String newName,
Class newType)
Replace the named argument with a new name and type.
|
static Signature |
returning(Class retval)
Create a new signature returning the given type.
|
Signature |
spread(String... names)
Spread the trailing [] argument into its component type assigning given names.
|
Signature |
spread(String[] names,
Class... types)
Spread the trailing [] argument into the given argument types
|
Signature |
spread(String baseName,
int count)
Spread the trailing [] argument into its component type assigning given names.
|
int[] |
to(Signature other)
Generate an array of argument offsets based on permuting this signature
to the given signature.
|
int[] |
to(String... otherArgPatterns)
Generate an array of argument offsets based on permuting this signature
to the given signature.
|
String |
toString()
Produce a human-readable representation of this signature.
|
MethodType |
type()
The current java.lang.invoke.MethodType for this Signature.
|
public String toString()
public static Signature returning(Class retval)
retval
- the return type for the new signaturepublic Signature changeReturn(Class retval)
retval
- the class for the new signature's return typepublic Signature asFold(Class retval)
retval
- the new return type for the new signaturepublic Signature appendArg(String name, Class type)
name
- the name of the argumenttype
- the type of the argumentpublic Signature appendArgs(String[] names, Class... types)
name
- the name of the argumenttype
- the type of the argumentpublic Signature prependArg(String name, Class type)
name
- the name of the argumenttype
- the type of the argumentpublic Signature prependArgs(String[] names, Class[] types)
name
- the name of the argumenttype
- the type of the argumentpublic Signature insertArg(int index, String name, Class type)
index
- the index at which to insertname
- the name of the new argumenttype
- the type of the new argumentpublic Signature insertArg(String beforeName, String name, Class type)
beforeName
- the name of the argument before which to insertname
- the name of the new argumenttype
- the type of the new argumentpublic Signature insertArgs(int index, String[] names, Class... types)
index
- the index at which to insertnames
- the names of the new argumentstypes
- the types of the new argumentspublic Signature insertArgs(String beforeName, String[] names, Class... types)
beforeName
- the name of the argument before which to insertnames
- the names of the new argumentstypes
- the types of the new argumentspublic Signature dropArg(String name)
name
- the name of the argument to droppublic Signature dropArg(int index)
index
- the index of the argument to droppublic Signature dropLast()
public Signature dropFirst()
public Signature replaceArg(String oldName, String newName, Class newType)
oldName
- the old name of the argumentnewName
- the new name of the argument; can be the same as oldoldName
- the new type of the argument; can be the same as oldpublic Signature spread(String[] names, Class... types)
public Signature spread(String... names)
public Signature spread(String baseName, int count)
public MethodType type()
public String[] argNames()
public String argName(int index)
index
- the index from which to get the argument namepublic int argOffset(String name)
name
- the argument name to search forpublic int argOffsets(String pattern)
name
- the argument name to search forpublic String firstArgName()
public String lastArgName()
public Class argType(int index)
index
- the index from which to get the argument typepublic Class firstArgType()
public Class lastArgType()
public Signature permute(String... permuteArgs)
permuteArgs
- the names of the arguments to preservepublic Signature exclude(String... excludeArgs)
excludeArgs
- the names of the arguments to excludepublic MethodHandle permuteWith(MethodHandle target, String... permuteArgs)
Signature sig = Signature.returning(String.class).appendArg("a", int.class).appendArg("b", int.class); MethodHandle handle = handleThatTakesOneInt(); MethodHandle newHandle = sig.permuteTo(handle, "b");
target
- the method handle to targetpermuteArgs
- the arguments to permutepublic SmartHandle permuteWith(SmartHandle target)
target
- the SmartHandle to use as a permutation targetpermuteWith(java.lang.invoke.MethodHandle, java.lang.String[])
public int[] to(Signature other)
other
- the signature to targetpublic int[] to(String... otherArgPatterns)
otherArgPatterns
- the argument name patterns to permuteCopyright © 2015. All rights reserved.