|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.infoway.messagebuilder.util.iterator.EmptyIterable<T>
T
- - the element type of the iterable.public class EmptyIterable<T>
A utility that performs nullness checking on an iterable. If an iterable is null, then an empty iterable is returned, preventing a NullPointerException.
A typical use of this class is as follows:
import static ca.infoway.messagebuilder.util.iterator.EmptyIterable.nullSafeIterable;
...
public void doMethod() {
for (String text : nullSafeIterable(getTextCollection)) {
...
}
}
...
Constructor Summary | |
---|---|
EmptyIterable()
|
Method Summary | ||
---|---|---|
static
|
nullSafeIterable(Iterable<T> i)
Check the incoming iterable type to see if it's null. |
|
static
|
nullSafeIterable(T[] i)
Check the incoming array to see if it's null. |
|
static
|
nullSafeKeySetIterable(Map<K,V> map)
Check the incoming map to see if it's null. |
|
static
|
nullSafeValuesIterable(Map<K,V> map)
Check the incoming map to see if it's null. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EmptyIterable()
Method Detail |
---|
public static <T> Iterable<T> nullSafeIterable(Iterable<T> i)
Check the incoming iterable type to see if it's null.
T
- - the type of object to iterate overi
- - the iterable type that might be null
public static <T> Iterable<T> nullSafeIterable(T[] i)
Check the incoming array to see if it's null.
T
- - the element type of the arrayi
- - the array that might be null
public static <K,V> Iterable<K> nullSafeKeySetIterable(Map<K,V> map)
Check the incoming map to see if it's null. If not, return the keySet iterator, otherwise return an empty iterator.
K
- - the key type of the mapV
- - the value type of the mapmap
- - the map that might be null
public static <K,V> Iterable<V> nullSafeValuesIterable(Map<K,V> map)
Check the incoming map to see if it's null. If not, return the values iterator, otherwise return an empty iterator.
K
- - the key type of the mapV
- - the value type of the mapmap
- - the map that might be null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |