Class Transform
java.lang.Object
com.headius.invokebinder.transform.Transform
- Direct Known Subclasses:
Cast
,Catch
,Collect
,Convert
,Drop
,Filter
,FilterReturn
,Fold
,Insert
,Permute
,Spread
,TryFinally
,Varargs
Abstract reprensentation of some handle transform.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
buildClassArgument
(StringBuilder builder, Class cls) Build Java code to represent a single .class reference.protected static void
buildClassArguments
(StringBuilder builder, Class<?>[] types) Build a list of argument type classes suitable for inserting into Java code.protected static void
buildClassCast
(StringBuilder builder, Class cls) Build Java code to represent a cast to the given type.protected static void
buildPrimitiveJava
(StringBuilder builder, Object value) Build Java code to represent a literal primitive.abstract MethodType
down
(MethodType source) Apply this transform downward from an incoming MethodType, producing a new type.static String
generateMethodType
(MethodType source) Build Java code appropriate for standing up the given MethodType.abstract String
toJava
(MethodType incoming) Return a Java code representation of this transform.abstract String
toString()
Return a string representation of this transform.abstract MethodHandle
up
(MethodHandle target) Apply this transform upward from the given MethodHandle, producing a new handle.
-
Constructor Details
-
Transform
public Transform()
-
-
Method Details
-
up
Apply this transform upward from the given MethodHandle, producing a new handle.- Parameters:
target
- the target handle- Returns:
- the adapted handle
-
down
Apply this transform downward from an incoming MethodType, producing a new type.- Parameters:
source
- the source type- Returns:
- the new type
-
toString
Return a string representation of this transform. -
toJava
Return a Java code representation of this transform.- Returns:
- a Java code representation of this transform.
-
buildClassArguments
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
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
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
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
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
-