S
- The class of the PrimitiveArray that is to be instantiated by the builderpublic class PrimitiveArrayBuilder<S extends AbstractPrimitiveArray>
extends java.lang.Object
AbstractPrimitiveArray
<T>
PrimitiveArrayBuilder
follows the commonly used builder pattern, and is useful for
capturing the instantiation parameters of StructuredArray
s.
PrimitiveArrayBuilder
s can be created for "flat" and "nested" StructuredArray
constructs, and can range from the simplest forms used when default constructors are employed, to forms that
supply customized per-element construction arguments that can take construction context (such as index,
containing array, and arbitrary data passed in a contextCookie) into account.
PrimitiveArrayBuilder
to instantiate a PrimitiveLongArray is:
StructuredArray<MyElementClass> array = new PrimitiveArrayBuilder(PrimitiveLongArray.class, length). build();
An example of passing specific construction arguments to the array constructor is:
Constructor<MyArrayClass> constructor = MyArrayClass.class.getConstructor(int.Class, int.Class); StructuredArray<MyElementClass> array = new PrimitiveArrayBuilder( MyArrayClass.class, length). arrayCtorAndArgs(constructor, initArg1, initArg2). build();
Constructor and Description |
---|
PrimitiveArrayBuilder(java.lang.Class<S> arrayClass,
long length)
Constructs a new
PrimitiveArrayBuilder object for creating arrays of
type S with the given length. |
Modifier and Type | Method and Description |
---|---|
PrimitiveArrayBuilder<S> |
arrayCtorAndArgs(java.lang.reflect.Constructor<S> constructor,
java.lang.Object... args)
Set the
Constructor and construction arguments to be used in constructing arrays. |
PrimitiveArrayBuilder<S> |
arrayCtorAndArgs(CtorAndArgs<S> arrayCtorAndArgs)
Set the
CtorAndArgs to be used in constructing arrays. |
S |
build()
Build a
AbstractPrimitiveArray according to the information captured in this builder |
CtorAndArgs<S> |
getArrayCtorAndArgs()
Get the
CtorAndArgs describing the constructor and arguments used to instantiate arrays with
this builder. |
PrimitiveArrayModel<S> |
getArrayModel()
Get the
PrimitiveArrayModel that describes the arrays built by this builder |
PrimitiveArrayBuilder<S> |
resolve()
Resolve any not-yet-resolved constructor information needed by this builder.
|
public PrimitiveArrayBuilder(java.lang.Class<S> arrayClass, long length)
PrimitiveArrayBuilder
object for creating arrays of
type S with the given length.arrayClass
- The class of the array to be built by this builderlength
- The length of the array to be build by this builderpublic PrimitiveArrayBuilder<S> arrayCtorAndArgs(CtorAndArgs<S> arrayCtorAndArgs)
CtorAndArgs
to be used in constructing arrays.
Setting the means for array construction is Required if the array class (S) does not support a
default constructor, or if a non-default construction of the array instance is needed.arrayCtorAndArgs
- The constructor and arguments used for constructing arrayspublic PrimitiveArrayBuilder<S> arrayCtorAndArgs(java.lang.reflect.Constructor<S> constructor, java.lang.Object... args)
Constructor
and construction arguments to be used in constructing arrays.
Setting the means for array construction is Required if the array class (S) does not support a
default constructor, or if a non-default construction of the array instance is needed.constructor
- The constructor used for constructing arraysargs
- The construction arguments supplied for the constructorpublic PrimitiveArrayBuilder<S> resolve() throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
- if the array constructor or element constructor fail to resolve given
the current information in the builderpublic S build() throws java.lang.NoSuchMethodException
AbstractPrimitiveArray
according to the information captured in this builderAbstractPrimitiveArray
java.lang.NoSuchMethodException
- if the array constructor or element constructor fail to resolve given
the current information in the builderpublic PrimitiveArrayModel<S> getArrayModel()
PrimitiveArrayModel
that describes the arrays built by this builderPrimitiveArrayModel
that describes the arrays built by this builderpublic CtorAndArgs<S> getArrayCtorAndArgs()
CtorAndArgs
describing the constructor and arguments used to instantiate arrays with
this builder. May be null if non of arrayCtorAndArgs
,
resolve()
or
build()
have been called yet.CtorAndArgs
describing the constructor and arguments used to instantiate arrays with
this builder.