@HashCodeAndEqualsPlugin.Enhance public class ArrayFactory extends java.lang.Object implements CollectionFactory
CollectionFactory
that is capable of
creating an array of a given type with any number of given values.Modifier and Type | Class and Description |
---|---|
protected static interface |
ArrayFactory.ArrayCreator
An array creator is responsible for providing correct byte code instructions for creating an array
and for storing values into it.
|
protected class |
ArrayFactory.ArrayStackManipulation
A stack manipulation for creating an array as defined by the enclosing array factory.
|
Modifier and Type | Field and Description |
---|---|
private ArrayFactory.ArrayCreator |
arrayCreator
The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of
values inside it.
|
private TypeDescription.Generic |
componentType
The component type of the array this array factory is creating.
|
private StackManipulation.Size |
sizeDecrease
The decrease of stack size after each value storage operation.
|
Modifier | Constructor and Description |
---|---|
protected |
ArrayFactory(TypeDescription.Generic componentType,
ArrayFactory.ArrayCreator arrayCreator)
Creates a new array factory with a given
ArrayFactory.ArrayCreator
without inferring the type from the component type. |
Modifier and Type | Method and Description |
---|---|
static ArrayFactory |
forType(TypeDescription.Generic componentType)
Creates a new array factory for a given component type.
|
TypeDescription.Generic |
getComponentType()
The component type of this factory.
|
private static ArrayFactory.ArrayCreator |
makeArrayCreatorFor(TypeDefinition componentType)
Creates a suitable array creator for the given component type.
|
StackManipulation |
withValues(java.util.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.
|
private final TypeDescription.Generic componentType
private final ArrayFactory.ArrayCreator arrayCreator
@HashCodeAndEqualsPlugin.ValueHandling(value=IGNORE) private final StackManipulation.Size sizeDecrease
protected ArrayFactory(TypeDescription.Generic componentType, ArrayFactory.ArrayCreator arrayCreator)
ArrayFactory.ArrayCreator
without inferring the type from the component type. Normally,
forType(net.bytebuddy.description.type.TypeDescription.Generic)
should be used.componentType
- The component type of the array factory.arrayCreator
- The array creator responsible for providing the correct byte code instructions.public static ArrayFactory forType(TypeDescription.Generic componentType)
componentType
- The component type of the array that is to be build.private static ArrayFactory.ArrayCreator makeArrayCreatorFor(TypeDefinition componentType)
componentType
- The component type of the array to be created.public StackManipulation withValues(java.util.List<? extends StackManipulation> stackManipulations)
withValues
in interface CollectionFactory
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.public TypeDescription.Generic getComponentType()
getComponentType
in interface CollectionFactory