public class FunctionalUtils
extends java.lang.Object
Optional) or
creating monad-style operations.| Constructor and Description |
|---|
FunctionalUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> |
emptyConcurrentMap()
Return an empty concurrent map.
|
static <E> java.util.List<E> |
immutable(java.util.List<E> lst)
Like
Collections.unmodifiableList(List), but does not wrap already unmodifiable lists in the unmodifiable list class. |
static <E,F> java.util.Map<E,F> |
immutable(java.util.Map<E,F> map)
Like
Collections.unmodifiableMap(Map), but does not wrap already unmodifiable maps in the unmodifiable map class. |
static <E> java.util.Set<E> |
immutable(java.util.Set<E> set)
Like
Collections.unmodifiableSet(Set), but does not wrap already unmodifiable sets in the unmodifiable set class. |
static <E> java.util.Optional<E> |
ofThrowable(ThrowableSupplier<E> elem) |
static <E> java.util.Optional<E> |
ofThrowable(ThrowableSupplier<E> elem,
boolean printErrors) |
static <E> java.util.stream.Stream<E> |
streamFromOptional(java.util.Optional<E> opt)
I can't believe this isn't in the Java standard library for flat mapping between streams and optionals.
|
static <E> java.util.stream.Stream<E> |
streamOfThrowable(ThrowableSupplier<E> elem)
Returns either a singleton stream of the value computed by the argument, or an empty stream.
|
public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> emptyConcurrentMap()
K - The key type of the map.V - The value type of the map.public static <E> java.util.Optional<E> ofThrowable(ThrowableSupplier<E> elem, boolean printErrors)
public static <E> java.util.Optional<E> ofThrowable(ThrowableSupplier<E> elem)
public static <E> java.util.stream.Stream<E> streamOfThrowable(ThrowableSupplier<E> elem)
public static <E,F> java.util.Map<E,F> immutable(java.util.Map<E,F> map)
Collections.unmodifiableMap(Map), but does not wrap already unmodifiable maps in the unmodifiable map class.
This avoids memory bloat and/or stack overflows for deep wrapping of immutable collections (e.g., if
a constructor makes something immutable).public static <E> java.util.List<E> immutable(java.util.List<E> lst)
Collections.unmodifiableList(List), but does not wrap already unmodifiable lists in the unmodifiable list class.
This avoids memory bloat and/or stack overflows for deep wrapping of immutable collections (e.g., if
a constructor makes something immutable).public static <E> java.util.Set<E> immutable(java.util.Set<E> set)
Collections.unmodifiableSet(Set), but does not wrap already unmodifiable sets in the unmodifiable set class.
This avoids memory bloat and/or stack overflows for deep wrapping of immutable collections (e.g., if
a constructor makes something immutable).public static <E> java.util.stream.Stream<E> streamFromOptional(java.util.Optional<E> opt)