Class Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Iterator<T>static booleanarraysEquals(byte[] array1, int pos1, int len1, byte[] array2, int pos2, int len2) static <T> Iterator<T>static <D> List<D>Concatenates two lists into onestatic <T> Set<T>difference(Set<? extends T> a, Set<? extends T> b) Returns a difference of two setsstatic <K,V> Map<K, V> entriesToMap(Stream<? extends Map.Entry<? extends K, ? extends V>> stream) static <K,V, R> Map<K, R> entriesToMap(Stream<? extends Map.Entry<? extends K, ? extends V>> stream, Function<? super V, ? extends R> fn) static <T> Tstatic <T> Tstatic <T> Tstatic <T> booleanhasIntersection(Set<? extends T> a, Set<? extends T> b) static <T> Set<T>intersection(Set<? extends T> a, Set<? extends T> b) Returns an intersection of two setsstatic booleanisBijection(Map<?, ?> map) static <T> Stream<T>static <T> Stream<T>iterate(T seed, @NotNull Predicate<? super T> hasNext, @NotNull UnaryOperator<T> f) static <T> Iterator<T>static <T> Iterator<T>iteratorOf(T item) static <T> Iterator<T>iteratorOf(T... items) static <T> Iterator<T>iteratorOf(T item1, T item2) static <K,V> Map<K, V> static <T> Tstatic <T> Tstatic <T> List<T>listOf()Returns an emptyListstatic <T> List<T>listOf(T value) Returns aListof a provided elementstatic <T> List<T>listOf(T... items) Returns aListof provided elementsstatic <K,V> Map<K, V> mapOf()Returns an emptyMapstatic <K,V> Map<K, V> mapOf(K key1, V value1) Returns aMapof provided key and valuestatic <K,V> Map<K, V> mapOf(K key1, V value1, K key2, V value2) Returns aMapof provided keys and valuesstatic <K,V> Map<K, V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3) Returns aMapof provided keys and valuesstatic <K,V> Map<K, V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4) Returns aMapof provided keys and valuesstatic <K,V> Map<K, V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4, K key5, V value5) Returns aMapof provided keys and valuesstatic <K,V> Map<K, V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4, K key5, V value5, K key6, V value6) Returns aMapof provided keys and valuesstatic <T> BinaryOperator<T>static <T> TnonNullElse(T value1, T defaultValue) static StringnonNullElseEmpty(@Nullable String value) static <T> List<T>nonNullElseEmpty(@Nullable List<T> list) static <K,V> Map<K, V> nonNullElseEmpty(@Nullable Map<K, V> map) static <T> Set<T>nonNullElseEmpty(@Nullable Set<T> set) static <T> TnonNullElseGet(T value, Supplier<? extends T> defaultValue) static <T,E extends Throwable>
TnonNullOrException(T value, Supplier<@NotNull E> exceptionSupplier) static <V> Vstatic <V,A> V nullify(V value, @NotNull BiConsumer<? super V, A> action, A actionArg) static <V> Vstatic <T> Iterator<T>static <T> Set<T>setOf(T item) Returns aSetof a provided elementstatic <T> Set<T>setOf(T... items) Returns aSetof provided elementsstatic <T> StringtoString(Collection<? extends T> collection) static <T> StringtoString(Collection<? extends T> collection, int limit) static <K,V> String static <K,V> String static <T,R> Iterator<R> transformIterator(Iterator<? extends T> iterator, Function<? super T, ? extends R> fn) static <K,V, R> Map<K, R> transformMap(Map<? extends K, ? extends V> map, Function<? super V, ? extends R> function) static <T> Set<T>Returns a union of two sets
-
Field Details
-
TO_STRING_LIMIT
public static final int TO_STRING_LIMIT
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
get
-
nonNullElse
public static <T> T nonNullElse(@Nullable T value1, T defaultValue) -
nonNullElseGet
-
nonNullElseEmpty
-
nonNullElseEmpty
-
nonNullElseEmpty
-
nonNullElseEmpty
-
nonNullOrException
@NotNull public static <T,E extends Throwable> T nonNullOrException(@Nullable T value, Supplier<@NotNull E> exceptionSupplier) throws E - Throws:
E extends Throwable
-
nullify
@Contract("_, _ -> null") @Nullable public static <V> V nullify(@Nullable V value, @NotNull @NotNull Runnable action) -
nullify
@Contract("_, _ -> null") @Nullable public static <V> V nullify(@Nullable V value, @NotNull @NotNull Consumer<? super V> action) -
nullify
@Contract("_, _, _ -> null") @Nullable public static <V,A> V nullify(@Nullable V value, @NotNull @NotNull BiConsumer<? super V, A> action, A actionArg) -
arraysEquals
public static boolean arraysEquals(byte[] array1, int pos1, int len1, byte[] array2, int pos2, int len2) -
concat
Concatenates two lists into oneNo guarantee on a mutability of a resulting list is made, so list should be considered unmodifiable
If any of concatenated lists is modified, the behaviour of a concatenated list is undefined
-
setOf
Returns aSetof a provided element- See Also:
-
setOf
Returns aSetof provided elementsNo guarantee on a mutability of a resulting set is made, so set should be considered unmodifiable
This is a simple alternative to Java 9's
Set#ofmethod -
difference
Returns a difference of two setsNo guarantee on a mutability of a resulting set is made, so set should be considered unmodifiable
If any of provided sets is modified, the behaviour of a resulting set is undefined
-
intersection
Returns an intersection of two setsNo guarantee on a mutability of a resulting set is made, so set should be considered unmodifiable
If any of provided sets is modified, the behaviour of a resulting set is undefined
-
hasIntersection
-
union
Returns a union of two setsNo guarantee on a mutability of a resulting set is made, so set should be considered unmodifiable
If any of provided sets is modified, the behaviour of a resulting set is undefined
-
first
-
first
-
last
-
last
-
listOf
Returns an emptyList- See Also:
-
listOf
Returns aListof a provided element- See Also:
-
listOf
Returns aListof provided elementsNo guarantee on a mutability of a resulting list is made, so list should be considered unmodifiable
This is a simple alternative to Java 9's
List#ofmethod -
iteratorOf
-
iteratorOf
-
iteratorOf
-
iteratorOf
-
transformIterator
-
concat
-
append
-
prepend
-
mapOf
Returns an emptyMapNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
Returns aMapof provided key and valueNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
Returns aMapof provided keys and valuesNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
Returns aMapof provided keys and valuesNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
public static <K,V> Map<K,V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4) Returns aMapof provided keys and valuesNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
public static <K,V> Map<K,V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4, K key5, V value5) Returns aMapof provided keys and valuesNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
mapOf
public static <K,V> Map<K,V> mapOf(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4, K key5, V value5, K key6, V value6) Returns aMapof provided keys and valuesNo guarantee on a mutability of a resulting map is made, so map should be considered unmodifiable
This is a simple alternative to Java 9's
Map#ofmethod -
isBijection
-
iterate
-
iterate
public static <T> Stream<T> iterate(T seed, @NotNull @NotNull Predicate<? super T> hasNext, @NotNull @NotNull UnaryOperator<T> f) -
noMergeFunction
-
keysToMap
-
entriesToMap
-
entriesToMap
-
transformMap
-
toString
-
toString
-
toString
-
toString
-