java.lang.Object
net.bytebuddy.implementation.bytecode.collection.ArrayFactory
All Implemented Interfaces:
CollectionFactory

@Enhance public class ArrayFactory extends Object implements CollectionFactory
A CollectionFactory that is capable of creating an array of a given type with any number of given values.
  • Field Details

    • componentType

      private final TypeDescription.Generic componentType
      The component type of the array this array factory is creating.
    • arrayCreator

      private final ArrayFactory.ArrayCreator arrayCreator
      The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of values inside it.
    • sizeDecrease

      @ValueHandling(IGNORE) private final StackManipulation.Size sizeDecrease
      The decrease of stack size after each value storage operation.
  • Constructor Details

  • Method Details

    • forType

      public static ArrayFactory forType(TypeDescription.Generic componentType)
      Creates a new array factory for a given component type.
      Parameters:
      componentType - The component type of the array that is to be build.
      Returns:
      A new array factory for the given type.
    • makeArrayCreatorFor

      private static ArrayFactory.ArrayCreator makeArrayCreatorFor(TypeDefinition componentType)
      Creates a suitable array creator for the given component type.
      Parameters:
      componentType - The component type of the array to be created.
      Returns:
      A suitable array creator.
    • withValues

      public StackManipulation withValues(List<? extends StackManipulation> stackManipulations)
      Applies this collection factory in order to build a new collection where each element is represented by the given stack manipulations.
      Specified by:
      withValues in interface CollectionFactory
      Parameters:
      stackManipulations - A list of stack manipulations loading the values to be stored in the collection that is created by this factory in their given order.
      Returns:
      A stack manipulation that creates the collection represented by this collection factory.
    • getComponentType

      public TypeDescription.Generic getComponentType()
      The component type of this factory.
      Specified by:
      getComponentType in interface CollectionFactory
      Returns:
      A type description of this factory's component type.