public abstract class CollectionProviders
extends java.lang.Object
CollectionProvider
and
CollectionMapProvider
interfaces.Constructor and Description |
---|
CollectionProviders() |
Modifier and Type | Method and Description |
---|---|
static <T> CollectionProvider<T> |
castCollectionProvider(java.lang.Object object,
java.lang.Class<? extends T> objectsType,
boolean throwException)
Cast the given object to
CollectionProvider with a generic-safe
type of objects. |
static <T> java.util.Collection<T> |
getCollection(java.lang.Object object,
int index,
java.lang.Class<? extends T> objectsType,
boolean throwException)
Returns the collection with the given index from the given object.
|
static <K,T> java.util.Collection<T> |
getCollectionByKey(java.lang.Object object,
K key,
java.lang.Class<? extends T> objectsType,
boolean throwException)
Returns the collection with the given key from the given object.
|
static <K,T> java.util.Iterator<T> |
getCollectionByKeyIterator(java.lang.Object object,
K key,
java.lang.Class<? extends T> objectsType,
boolean throwException)
Returns the iterator of the collection with the given key from the given object.
|
static int |
getCollectionCount(java.lang.Object object)
Returns the number of collections in the given object.
|
static <T> java.util.Iterator<T> |
getCollectionIterator(java.lang.Object object,
int index,
java.lang.Class<? extends T> objectsType)
Returns the iterator of the collection with the given index from the given object.
|
static <T> java.util.Iterator<T> |
getCollectionIterator(java.lang.Object object,
int index,
java.lang.Class<? extends T> objectsType,
boolean throwException)
Returns the iterator of the collection with the given index from the given object.
|
public static <T> CollectionProvider<T> castCollectionProvider(java.lang.Object object, java.lang.Class<? extends T> objectsType, boolean throwException) throws java.lang.ClassCastException
CollectionProvider
with a generic-safe
type of objects.T
- the class of objects stored in the collectionsobject
- the object to castobjectsType
- the class of objects stored in the collectionsthrowException
- flag determining whether the ClassCastException is thrown
(true) or null is returned (false), if the
given object
cannot be castobject
java.lang.ClassCastException
- if the given object is not CollectionProvider
or the class of objects stored in the collections is not objectsType
public static int getCollectionCount(java.lang.Object object)
CollectionProvider
, the actual
collection count is returned. Otherwise, a zero is returned.object
- the object the number of collections to getpublic static <T> java.util.Collection<T> getCollection(java.lang.Object object, int index, java.lang.Class<? extends T> objectsType, boolean throwException) throws java.lang.IndexOutOfBoundsException, java.lang.ClassCastException
CollectionProvider
interface with
the compatible objectsType
.
Note that the returned collection (typically) cannot be modified.T
- the class of objects stored in the collectionsobject
- the object the collection of which to getindex
- the index of the collection to returnobjectsType
- the class of objects stored in the collectionsthrowException
- flag determining whether the ClassCastException is thrown
(true) or null is returned (false), if the
given object
cannot be cast to compatible CollectionProvider
java.lang.IndexOutOfBoundsException
- if the given index is negative or
greater or equal to getCollectionCount(java.lang.Object)
java.lang.ClassCastException
- if the given object is not CollectionProvider
or the class of objects stored in the collections is not objectsType
public static <T> java.util.Iterator<T> getCollectionIterator(java.lang.Object object, int index, java.lang.Class<? extends T> objectsType, boolean throwException) throws java.lang.IndexOutOfBoundsException, java.lang.ClassCastException
CollectionProvider
interface with
the compatible objectsType
.T
- the class of objects returned by the iteratorobject
- the object the collection iterator of which to getindex
- the index of the collection iterator to returnobjectsType
- the class of objects returned by the iteratorthrowException
- flag determining whether the ClassCastException is thrown
(true) or null is returned (false), if the
given object
cannot be cast to compatible CollectionProvider
java.lang.IndexOutOfBoundsException
- if the given index is negative or
greater or equal to getCollectionCount(java.lang.Object)
java.lang.ClassCastException
- if the given object is not CollectionProvider
or the class of objects stored in the collections is not objectsType
public static <T> java.util.Iterator<T> getCollectionIterator(java.lang.Object object, int index, java.lang.Class<? extends T> objectsType) throws java.lang.IndexOutOfBoundsException
CollectionProvider
interface with
the compatible objectsType
.T
- the class of objects returned by the iteratorobject
- the object the collection iterator of which to getindex
- the index of the collection iterator to returnobjectsType
- the class of objects returned by the iteratorjava.lang.IndexOutOfBoundsException
- if the given object is not CollectionProvider
,
the class of objects stored in the collections is not objectsType
,
the given index is negative, or the index is greater or equal
to getCollectionCount(java.lang.Object)
public static <K,T> java.util.Collection<T> getCollectionByKey(java.lang.Object object, K key, java.lang.Class<? extends T> objectsType, boolean throwException) throws java.lang.ClassCastException
CollectionMapProvider
interface with
the compatible objectsType
.
Note that the returned collection (typically) cannot be modified.K
- the type of keys used for accessing the collectionsT
- the class of objects stored in the collectionsobject
- the object the collection of which to getkey
- the key of the collection to returnobjectsType
- the class of objects stored in the collectionsthrowException
- flag determining whether the ClassCastException is thrown
(true) or null is returned (false), if the
given object
cannot be cast to compatible CollectionMapProvider
java.lang.ClassCastException
- if the given object is not CollectionMapProvider
or the class of objects stored in the collections is not objectsType
public static <K,T> java.util.Iterator<T> getCollectionByKeyIterator(java.lang.Object object, K key, java.lang.Class<? extends T> objectsType, boolean throwException) throws java.lang.ClassCastException
CollectionMapProvider
interface with
the compatible objectsType
.K
- the type of keys used for accessing the collectionsT
- the class of objects returned by the iteratorobject
- the object the collection iterator of which to getkey
- the key of the collection iterator to returnobjectsType
- the class of objects returned by the iteratorthrowException
- flag determining whether the ClassCastException is thrown
(true) or null is returned (false), if the
given object
cannot be cast to compatible CollectionMapProvider
java.lang.ClassCastException
- if the given object is not CollectionMapProvider
or the class of objects stored in the collections is not objectsType