introduce single-param null-aware of(item)

This commit is contained in:
Gregory.Shrago
2016-07-08 03:35:24 +03:00
parent 1ca2a0cfad
commit 6d612e35a5
@@ -148,6 +148,14 @@ public abstract class JBIterable<E> implements Iterable<E> {
};
}
/**
* Returns a {@code JBIterable} containing the one {@code element}.
*/
@NotNull
public static <E> JBIterable<E> of(@Nullable E element) {
return element == null ? JBIterable.<E>empty() : from(Collections.singletonList(element));
}
/**
* Returns a {@code JBIterable} containing {@code elements} in the specified order.
*/