Class ArrayFactory
java.lang.Object
net.bytebuddy.implementation.bytecode.collection.ArrayFactory
- All Implemented Interfaces:
CollectionFactory
A
CollectionFactory
that is capable of
creating an array of a given type with any number of given values.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
An array creator is responsible for providing correct byte code instructions for creating an array and for storing values into it.protected class
A stack manipulation for creating an array as defined by the enclosing array factory. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ArrayFactory.ArrayCreator
The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of values inside it.private final TypeDescription.Generic
The component type of the array this array factory is creating.private final StackManipulation.Size
The decrease of stack size after each value storage operation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ArrayFactory
(TypeDescription.Generic componentType, ArrayFactory.ArrayCreator arrayCreator) Creates a new array factory with a givenArrayFactory.ArrayCreator
without inferring the type from the component type. -
Method Summary
Modifier and TypeMethodDescriptionstatic ArrayFactory
forType
(TypeDescription.Generic componentType) Creates a new array factory for a given component type.The component type of this factory.private static ArrayFactory.ArrayCreator
makeArrayCreatorFor
(TypeDefinition componentType) Creates a suitable array creator for the given component type.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.
-
Field Details
-
componentType
The component type of the array this array factory is creating. -
arrayCreator
The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of values inside it. -
sizeDecrease
The decrease of stack size after each value storage operation.
-
-
Constructor Details
-
ArrayFactory
protected ArrayFactory(TypeDescription.Generic componentType, ArrayFactory.ArrayCreator arrayCreator) Creates a new array factory with a givenArrayFactory.ArrayCreator
without inferring the type from the component type. Normally,forType(net.bytebuddy.description.type.TypeDescription.Generic)
should be used.- Parameters:
componentType
- The component type of the array factory.arrayCreator
- The array creator responsible for providing the correct byte code instructions.
-
-
Method Details
-
forType
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
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
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 interfaceCollectionFactory
- 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
The component type of this factory.- Specified by:
getComponentType
in interfaceCollectionFactory
- Returns:
- A type description of this factory's component type.
-