public class Signature
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String[] |
argNames |
private java.lang.invoke.MethodType |
methodType |
| Constructor and Description |
|---|
Signature(java.lang.Class retval)
Construct a new signature with the given return value.
|
Signature(java.lang.Class retval,
java.lang.Class[] argTypes,
java.lang.String... argNames)
Construct a new signature with the given return value, argument types,
and argument names.
|
Signature(java.lang.invoke.MethodType methodType,
java.lang.String... argNames)
Construct a new signature with the given method type and argument names.
|
| Modifier and Type | Method and Description |
|---|---|
Signature |
appendArg(java.lang.String name,
java.lang.Class type)
Append an argument (name + type) to the signature.
|
Signature |
appendArgs(java.lang.String[] names,
java.lang.Class... types)
Append an argument (name + type) to the signature.
|
java.lang.String |
argName(int index)
Retrieve the name of the argument at the given index.
|
java.lang.String[] |
argNames()
The current argument names for this signature.
|
int |
argOffset(java.lang.String name)
Retrieve the offset of the given argument name in this signature's
arguments.
|
int |
argOffsets(java.lang.String pattern)
Retrieve the offset of the given argument name in this signature's
arguments.
|
java.lang.Class |
argType(int index)
Get the argument type at the given index.
|
Signature |
asFold(java.lang.Class retval)
Produce a new signature based on this one with a different return type.
|
Signature |
changeReturn(java.lang.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(java.lang.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(java.lang.String... excludeArgs)
Create a new signature containing the same return value as this one, but
omitting the specified arguments.
|
java.lang.String |
firstArgName()
Get the first argument name.
|
java.lang.Class |
firstArgType()
Get the first argument type.
|
Signature |
insertArg(int index,
java.lang.String name,
java.lang.Class type)
Insert an argument (name + type) into the signature.
|
Signature |
insertArg(java.lang.String beforeName,
java.lang.String name,
java.lang.Class type)
Insert an argument (name + type) into the signature before the argument
with the given name.
|
Signature |
insertArgs(int index,
java.lang.String[] names,
java.lang.Class... types)
Insert arguments (names + types) into the signature.
|
Signature |
insertArgs(java.lang.String beforeName,
java.lang.String[] names,
java.lang.Class... types)
Insert arguments (names + types) into the signature before the argument
with the given name.
|
java.lang.String |
lastArgName()
Get the last argument name.
|
java.lang.Class |
lastArgType()
Get the last argument type.
|
private int[] |
nonMatchingTo(java.lang.String... otherArgNames) |
Signature |
permute(java.lang.String... permuteArgs)
Create a new signature containing the same return value as this one, but
only the specified arguments.
|
java.lang.invoke.MethodHandle |
permuteWith(java.lang.invoke.MethodHandle target,
java.lang.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(java.lang.String name,
java.lang.Class type)
Prepend an argument (name + type) to the signature.
|
Signature |
prependArgs(java.lang.String[] names,
java.lang.Class[] types)
Prepend an argument (name + type) to the signature.
|
Signature |
replaceArg(java.lang.String oldName,
java.lang.String newName,
java.lang.Class newType)
Replace the named argument with a new name and type.
|
static Signature |
returning(java.lang.Class retval)
Create a new signature returning the given type.
|
Signature |
spread(java.lang.String... names)
Spread the trailing [] argument into its component type assigning given names.
|
Signature |
spread(java.lang.String[] names,
java.lang.Class... types)
Spread the trailing [] argument into the given argument types
|
Signature |
spread(java.lang.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(java.lang.String... otherArgPatterns)
Generate an array of argument offsets based on permuting this signature
to the given signature.
|
java.lang.String |
toString()
Produce a human-readable representation of this signature.
|
java.lang.invoke.MethodType |
type()
The current java.lang.invoke.MethodType for this Signature.
|
private final java.lang.invoke.MethodType methodType
private final java.lang.String[] argNames
Signature(java.lang.Class retval)
retval - the return value for the new signatureSignature(java.lang.Class retval,
java.lang.Class[] argTypes,
java.lang.String... argNames)
retval - the return value for the new signatureargTypes - the argument types for the new signatureargNames - the argument names for the new signatureSignature(java.lang.invoke.MethodType methodType,
java.lang.String... argNames)
methodType - the method type for the new signatureargNames - the argument names for the new signaturepublic java.lang.String toString()
toString in class java.lang.Objectpublic static Signature returning(java.lang.Class retval)
retval - the return type for the new signaturepublic Signature changeReturn(java.lang.Class retval)
retval - the class for the new signature's return typepublic Signature asFold(java.lang.Class retval)
retval - the new return type for the new signaturepublic Signature appendArg(java.lang.String name, java.lang.Class type)
name - the name of the argumenttype - the type of the argumentpublic Signature appendArgs(java.lang.String[] names, java.lang.Class... types)
name - the name of the argumenttype - the type of the argumentpublic Signature prependArg(java.lang.String name, java.lang.Class type)
name - the name of the argumenttype - the type of the argumentpublic Signature prependArgs(java.lang.String[] names, java.lang.Class[] types)
name - the name of the argumenttype - the type of the argumentpublic Signature insertArg(int index, java.lang.String name, java.lang.Class type)
index - the index at which to insertname - the name of the new argumenttype - the type of the new argumentpublic Signature insertArg(java.lang.String beforeName, java.lang.String name, java.lang.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, java.lang.String[] names, java.lang.Class... types)
index - the index at which to insertnames - the names of the new argumentstypes - the types of the new argumentspublic Signature insertArgs(java.lang.String beforeName, java.lang.String[] names, java.lang.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(java.lang.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(java.lang.String oldName, java.lang.String newName, java.lang.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(java.lang.String[] names, java.lang.Class... types)
public Signature spread(java.lang.String... names)
public Signature spread(java.lang.String baseName, int count)
public java.lang.invoke.MethodType type()
public java.lang.String[] argNames()
public java.lang.String argName(int index)
index - the index from which to get the argument namepublic int argOffset(java.lang.String name)
name - the argument name to search forpublic int argOffsets(java.lang.String pattern)
name - the argument name to search forpublic java.lang.String firstArgName()
public java.lang.String lastArgName()
public java.lang.Class argType(int index)
index - the index from which to get the argument typepublic java.lang.Class firstArgType()
public java.lang.Class lastArgType()
public Signature permute(java.lang.String... permuteArgs)
permuteArgs - the names of the arguments to preservepublic Signature exclude(java.lang.String... excludeArgs)
excludeArgs - the names of the arguments to excludepublic java.lang.invoke.MethodHandle permuteWith(java.lang.invoke.MethodHandle target,
java.lang.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(java.lang.String... otherArgPatterns)
otherArgPatterns - the argument name patterns to permuteprivate int[] nonMatchingTo(java.lang.String... otherArgNames)