I
- the class of item contained in the collection, if anypublic final class CollectionsZ<I>
extends java.lang.Object
Arrays
and Collections
classes.
The class is meant to look like the Collections
class in
use. For methods that can be written statically, the class may be used as
such. However, certain operations that need tighter links to particular class
specifications require explicit type definition in the method prototypes.
To support this, the class provides the of(java.lang.Class<T>)
method, which creates a
type-bound instance of the utility class, whose instance methods may then
operate under this more controlled context. arrayConcat(I[]...)
is an
illustrative example of a method that needs this context:
String[] asFoo = { "foo", "Foo", "FOO" } ; String[] asBar = { "bar", "Bar", "BAR" } ; String[] asFoobar = CollectionsZ.of( String.class ) .arrayConcat( asFoo, asBar ) ; assertEquals( 6, asFoobar.length ) ;
Modifier and Type | Method and Description |
---|---|
I[] |
arrayConcat(I[]... aArrays)
Concatenates an arbitrary number of arrays of the same object type
|
protected I[] |
newArray(int nSize)
Creates a new empty array of the specified size.
|
static <T> CollectionsZ<T> |
of(java.lang.Class<T> cls)
This method provides a static way to obtain a parameterized instance of
the
CollectionsZ class so that its other nifty methods may be
invoked under these conditions. |
I[] |
toArray(java.util.Collection<I> a)
Provides a sane implementation of
toArray() for collections which
returns an array of the object's type. |
public static <T> CollectionsZ<T> of(java.lang.Class<T> cls)
CollectionsZ
class so that its other nifty methods may be
invoked under these conditions.T
- the class of item contained in the collectioncls
- the class of item contained in the collectionprotected I[] newArray(int nSize)
nSize
- the initial capacitypublic I[] toArray(java.util.Collection<I> a)
toArray()
for collections which
returns an array of the object's type.a
- the collection to be converted to an arraynull
if the
input was also null