Class Transform
- java.lang.Object
-
- com.headius.invokebinder.transform.Transform
-
-
Constructor Summary
Constructors Constructor Description Transform()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidbuildClassArgument(StringBuilder builder, Class cls)Build Java code to represent a single .class reference.protected static voidbuildClassArguments(StringBuilder builder, Class<?>[] types)Build a list of argument type classes suitable for inserting into Java code.protected static voidbuildClassCast(StringBuilder builder, Class cls)Build Java code to represent a cast to the given type.protected static voidbuildPrimitiveJava(StringBuilder builder, Object value)Build Java code to represent a literal primitive.abstract MethodTypedown(MethodType source)Apply this transform downward from an incoming MethodType, producing a new type.static StringgenerateMethodType(MethodType source)Build Java code appropriate for standing up the given MethodType.abstract StringtoJava(MethodType incoming)Return a Java code representation of this transform.abstract StringtoString()Return a string representation of this transform.abstract MethodHandleup(MethodHandle target)Apply this transform upward from the given MethodHandle, producing a new handle.
-
-
-
Method Detail
-
up
public abstract MethodHandle up(MethodHandle target)
Apply this transform upward from the given MethodHandle, producing a new handle.- Parameters:
target- the target handle- Returns:
- the adapted handle
-
down
public abstract MethodType down(MethodType source)
Apply this transform downward from an incoming MethodType, producing a new type.- Parameters:
source- the source type- Returns:
- the new type
-
toString
public abstract String toString()
Return a string representation of this transform.
-
toJava
public abstract String toJava(MethodType incoming)
Return a Java code representation of this transform.- Returns:
- a Java code representation of this transform.
-
buildClassArguments
protected static void buildClassArguments(StringBuilder builder, Class<?>[] types)
Build a list of argument type classes suitable for inserting into Java code. This will be an argument list of the form "pkg.Cls1.class, pkg.Cls2[].class, primtype.class, ..."- Parameters:
builder- the builder in which to build the argument listtypes- the classes from which to create the argument list
-
buildClassArgument
protected static void buildClassArgument(StringBuilder builder, Class cls)
Build Java code to represent a single .class reference. This will be an argument of the form "pkg.Cls1.class" or "pkg.Cls2[].class" or "primtype.class"- Parameters:
builder- the builder in which to build the argumentcls- the type for the argument
-
buildClassCast
protected static void buildClassCast(StringBuilder builder, Class cls)
Build Java code to represent a cast to the given type. This will be an argument of the form "(pkg.Cls1)" or "(pkg.Cls2[])" or "(primtype)"- Parameters:
builder- the builder in which to build the argumentcls- the type for the argument
-
buildPrimitiveJava
protected static void buildPrimitiveJava(StringBuilder builder, Object value)
Build Java code to represent a literal primitive. This will append L or F as appropriate for long and float primitives.- Parameters:
builder- the builder in which to generate the codevalue- the primitive value to generate from
-
generateMethodType
public static String generateMethodType(MethodType source)
Build Java code appropriate for standing up the given MethodType.- Parameters:
source- the MethodType for which to build Java code- Returns:
- Java code suitable for building the given MethodType
-
-