public class PrimitiveByteArray extends AbstractPrimitiveArray
Constructor and Description |
---|
PrimitiveByteArray()
Default constructor
|
PrimitiveByteArray(PrimitiveByteArray sourceArray)
Copying constructor
|
Modifier and Type | Method and Description |
---|---|
byte[] |
asArray()
Get a reference to a byte[] that represents the contents of this array.
|
static <A extends PrimitiveByteArray> |
copyInstance(A source)
Create a new <A extends
PrimitiveByteArray > instance, using a copy constructor to
replicate the contents of the given source array |
static <A extends PrimitiveByteArray> |
copyInstance(java.lang.invoke.MethodHandles.Lookup lookup,
A source)
Create a new <A extends
PrimitiveByteArray > instance, using a copy constructor to
replicate the contents of the given source array |
byte |
get(int index)
Get the value of an element in the array.
|
byte |
get(long index)
Get the value of an element in the array.
|
long |
getLength()
Get the length of the array
|
static <A extends PrimitiveByteArray> |
newInstance(java.lang.Class<A> arrayClass,
long length)
Create a new instance of <A extends
PrimitiveByteArray > with a given length. |
static <A extends PrimitiveByteArray> |
newInstance(CtorAndArgs<A> arrayCtorAndArgs,
long length)
Create a new instance of <A extends
PrimitiveByteArray > with a given length,
array constructor, and array constructor arguments. |
static PrimitiveByteArray |
newInstance(long length)
Create a new instance of
PrimitiveByteArray with a given length. |
static <A extends PrimitiveByteArray> |
newInstance(long length,
java.lang.reflect.Constructor<A> arrayConstructor,
java.lang.Object... arrayConstructorArgs)
Create a new instance of <A extends
PrimitiveByteArray > with a given length,
array constructor, and array constructor arguments. |
static <A extends PrimitiveByteArray> |
newInstance(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<A> arrayClass,
long length)
Create a new instance of <A extends
PrimitiveByteArray > with a given length. |
void |
set(int index,
byte value)
set the value of an element in the array.
|
void |
set(long index,
byte value)
set the value of an element in the array.
|
public PrimitiveByteArray()
public PrimitiveByteArray(PrimitiveByteArray sourceArray)
sourceArray
- the array to copypublic byte[] asArray() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if array is too long to represent as a byte[]public long getLength()
public byte get(int index)
index
- the index of the elementpublic byte get(long index)
index
- the index of the elementpublic void set(int index, byte value)
index
- the index of the element to setvalue
- the value to assign to the elementpublic void set(long index, byte value)
index
- the index of the element to setvalue
- the value to assign to the elementpublic static PrimitiveByteArray newInstance(long length)
PrimitiveByteArray
with a given length.length
- the length of the array.PrimitiveByteArray
with the given lengthpublic static <A extends PrimitiveByteArray> A newInstance(java.lang.Class<A> arrayClass, long length)
PrimitiveByteArray
> with a given length.A
- The class of the array to be created (extends PrimitiveByteArray)arrayClass
- The class of the array to be created (extends PrimitiveByteArray)length
- the length of the array.PrimitiveByteArray
> with a given lengthpublic static <A extends PrimitiveByteArray> A newInstance(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<A> arrayClass, long length)
PrimitiveByteArray
> with a given length.A
- The class of the array to be created (extends PrimitiveByteArray)lookup
- The lookup object to use for accessing the array's constructorarrayClass
- The class of the array to be created (extends PrimitiveByteArray)length
- the length of the array.PrimitiveByteArray
> with a given lengthpublic static <A extends PrimitiveByteArray> A newInstance(CtorAndArgs<A> arrayCtorAndArgs, long length)
PrimitiveByteArray
> with a given length,
array constructor, and array constructor arguments.A
- The class of the array to be created (extends PrimitiveByteArray)length
- The length of the array.arrayCtorAndArgs
- for creating the arrayPrimitiveByteArray
>public static <A extends PrimitiveByteArray> A newInstance(long length, java.lang.reflect.Constructor<A> arrayConstructor, java.lang.Object... arrayConstructorArgs)
PrimitiveByteArray
> with a given length,
array constructor, and array constructor arguments.A
- The class of the array to be created (extends PrimitiveByteArray)length
- The length of the array.arrayConstructor
- The array constructor to usearrayConstructorArgs
- The arguments to pass to the array constructorPrimitiveByteArray
>public static <A extends PrimitiveByteArray> A copyInstance(A source) throws java.lang.NoSuchMethodException
PrimitiveByteArray
> instance, using a copy constructor to
replicate the contents of the given source arrayA
- The class of the array to be created (extends PrimitiveByteArray)source
- The array to replicatePrimitiveByteArray
> copied from the source arrayjava.lang.NoSuchMethodException
- if <A> does not have a copy constructorpublic static <A extends PrimitiveByteArray> A copyInstance(java.lang.invoke.MethodHandles.Lookup lookup, A source) throws java.lang.NoSuchMethodException
PrimitiveByteArray
> instance, using a copy constructor to
replicate the contents of the given source arrayA
- The class of the array to be created (extends PrimitiveByteArray)lookup
- The lookup object to use for accessing the array's constructorsource
- The array to replicatePrimitiveByteArray
> copied from the source arrayjava.lang.NoSuchMethodException
- if <A> does not have a copy constructor