Class HashCodeMethod.Appender

java.lang.Object
net.bytebuddy.implementation.HashCodeMethod.Appender
All Implemented Interfaces:
ByteCodeAppender
Enclosing class:
HashCodeMethod

@Enhance protected static class HashCodeMethod.Appender extends Object implements ByteCodeAppender
A byte code appender to implement a hash code method.
  • Field Details

    • initialValue

      private final StackManipulation initialValue
      Loads the initial hash code onto the operand stack.
    • multiplier

      private final int multiplier
      A multiplier for each value before adding a field's hash code value.
    • fieldDescriptions

      private final List<FieldDescription.InDefinedShape> fieldDescriptions
      A list of fields to include in the hash code computation.
    • nonNullable

      private final ElementMatcher<? super FieldDescription.InDefinedShape> nonNullable
      A matcher to determine fields of a reference type that cannot be null.
  • Constructor Details

    • Appender

      protected Appender(StackManipulation initialValue, int multiplier, List<FieldDescription.InDefinedShape> fieldDescriptions, ElementMatcher<? super FieldDescription.InDefinedShape> nonNullable)
      Creates a new appender for implementing a hash code method.
      Parameters:
      initialValue - Loads the initial hash code onto the operand stack.
      multiplier - A multiplier for each value before adding a field's hash code value.
      fieldDescriptions - A list of fields to include in the hash code computation.
      nonNullable - A matcher to determine fields of a reference type that cannot be null.
  • Method Details

    • apply

      public ByteCodeAppender.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod)
      Applies this byte code appender to a type creation process.
      Specified by:
      apply in interface ByteCodeAppender
      Parameters:
      methodVisitor - The method visitor to which the byte code appender writes its code to.
      implementationContext - The implementation context of the current type creation process.
      instrumentedMethod - The method that is the target of the instrumentation.
      Returns:
      The required size for the applied byte code to run.