Class VarHandleAccessorGenerator

java.lang.Object
dev.morphia.critter.parser.gizmo.BaseGizmoGenerator
dev.morphia.critter.parser.gizmo.VarHandleAccessorGenerator

public class VarHandleAccessorGenerator extends BaseGizmoGenerator
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.
  • 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 a VarHandle.
      Parameters:
      entity - the entity class that owns the field
      critterClassLoader - the class loader that will receive the generated bytecode
      field - 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 using MethodHandles.
      Parameters:
      entity - the entity class that owns the getter
      critterClassLoader - the class loader that will receive the generated bytecode
      method - the ASM method node representing the getter
  • Method Details

    • isPrimitive

      public boolean isPrimitive()
      Returns true if the property type is a Java primitive.
      Returns:
      true if the property type is primitive
    • getWrapperType

      public String 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