Package dev.morphia.critter.parser.gizmo
Class VarHandleAccessorGenerator
java.lang.Object
dev.morphia.critter.parser.gizmo.BaseGizmoGenerator
dev.morphia.critter.parser.gizmo.VarHandleAccessorGenerator
Generates a Gizmo-based
PropertyAccessor implementation that uses
VarHandle (for fields) or MethodHandle (for getter/setter pairs)
to access a single property of a Morphia entity class.-
Field Summary
Fields inherited from class dev.morphia.critter.parser.gizmo.BaseGizmoGenerator
baseName, critterClassLoader, entity, generatedType -
Constructor Summary
ConstructorsConstructorDescriptionVarHandleAccessorGenerator(Class<?> entity, dev.morphia.critter.CritterClassLoader critterClassLoader, org.objectweb.asm.tree.FieldNode field) Creates a generator for a field-based property accessor using aVarHandle.VarHandleAccessorGenerator(Class<?> entity, dev.morphia.critter.CritterClassLoader critterClassLoader, org.objectweb.asm.tree.MethodNode method) Creates a generator for a method-based property accessor usingMethodHandles. -
Method Summary
Modifier and TypeMethodDescriptionemit()Emits the generated property accessor class and returns this generator.Returns the fully-qualified name of the wrapper class for the property type, or the property type itself if it is not a primitive.booleanReturnstrueif the property type is a Java primitive.Methods inherited from class dev.morphia.critter.parser.gizmo.BaseGizmoGenerator
getBuilder, getCreator
-
Constructor Details
-
VarHandleAccessorGenerator
public VarHandleAccessorGenerator(Class<?> entity, dev.morphia.critter.CritterClassLoader critterClassLoader, org.objectweb.asm.tree.FieldNode field) Creates a generator for a field-based property accessor using aVarHandle.- Parameters:
entity- the entity class that owns the fieldcritterClassLoader- the class loader that will receive the generated bytecodefield- the ASM field node representing the property
-
VarHandleAccessorGenerator
public VarHandleAccessorGenerator(Class<?> entity, dev.morphia.critter.CritterClassLoader critterClassLoader, org.objectweb.asm.tree.MethodNode method) Creates a generator for a method-based property accessor usingMethodHandles.- Parameters:
entity- the entity class that owns the gettercritterClassLoader- the class loader that will receive the generated bytecodemethod- the ASM method node representing the getter
-
-
Method Details
-
isPrimitive
public boolean isPrimitive()Returnstrueif the property type is a Java primitive.- Returns:
trueif the property type is primitive
-
getWrapperType
Returns the fully-qualified name of the wrapper class for the property type, or the property type itself if it is not a primitive.- Returns:
- the wrapper type name
-
emit
Emits the generated property accessor class and returns this generator.- Returns:
- this generator after emitting
-