public class Signature extends Object
| Modifier and Type | Method | 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.
|
int |
argCount() |
The current argument count.
|
String |
argName(int index) |
Retrieve the name of the argument at the given index.
|
Signature |
argName(int index,
String name) |
Set the argument name 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 |
argType(int index,
Class<?> type) |
Set 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 |
collect(String newName,
String oldPattern) |
Collect sequential arguments matching pattern into an array.
|
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 |
dropFirst(int n) |
Drop the specified number of first arguments from this signature.
|
Signature |
dropLast() |
Drop the last argument from this signature.
|
Signature |
dropLast(int n) |
Drop the specified number of last arguments from this signature.
|
boolean |
equals(Object o) |
|
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.
|
static Signature |
from(Class<?> retval,
Class<?>[] argTypes,
String... argNames) |
Create a new signature based on the given return value, argument types, and argument names
|
int |
hashCode() |
|
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.
|
SmartHandle |
permuteWith(SmartHandle target) |
Produce a new SmartHandle by permuting this Signature's arguments to the
Signature of a target SmartHandle.
|
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.
|
Signature |
prependArg(String name,
Class<?> type) |
Prepend an argument (name + type) to the signature.
|
Signature |
prependArgs(String[] names,
Class<?>... types) |
Prepend arguments (names + types) 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 its component type assigning given names.
|
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 static Signature from(Class<?> retval, Class<?>[] argTypes, String... argNames)
retval - the type of the return valueargTypes - the types of the argumentsargNames - the names of the argumentspublic 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)
names - the names of the argumentstypes - the types 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)
names - the names of the argumentstypes - the types of the argumentspublic 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 dropLast(int n)
n - number of arguments to droppublic Signature dropFirst()
public Signature dropFirst(int n)
n - number of arguments to droppublic 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 oldnewType - the new type of the argument; can be the same as oldpublic Signature spread(String[] names, Class<?>... types)
names - names to use for the decomposed argumentstypes - types to use for the decomposed argumentspublic Signature spread(String... names)
names - names to use for the decomposed argumentspublic Signature spread(String baseName, int count)
baseName - base name of the spread argumentscount - number of arguments into which the last argument will decomposepublic Signature collect(String newName, String oldPattern)
newName - the name of the new array argumentoldPattern - the pattern of arguments to collectpublic MethodType type()
public int argCount()
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)
pattern - the argument name to search forpublic String firstArgName()
public String lastArgName()
public Signature argName(int index, String name)
index - the index at which to set the argument namename - the name to setpublic Class<?> argType(int index)
index - the index from which to get the argument typepublic Class<?> firstArgType()
public Class<?> lastArgType()
public Signature argType(int index, Class<?> type)
index - the index at which to set the argument typetype - the type to setpublic 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 © 2018. All rights reserved.