Top Fields Constructors Methods
org.apache.sshd.common.util

public final Class GenericUtils

extends Object
Class Inheritance
Imports
java.time.Duration, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .Deque, .EnumSet, .HashSet, .Iterator, .LinkedList, .List, .NavigableSet, .Objects, .Set, .SortedSet, .TreeSet, java.util.concurrent.atomic.AtomicReference, java.util.function.Consumer, .Function, .Predicate, .Supplier, java.util.stream.Collector, .Collectors, .Stream, .StreamSupport, org.apache.sshd.common.util.functors.UnaryEquator

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final Comparator<String>
public static final boolean[]
public static final byte[]
public static final char[]
public static final Object[]
public static final String[]
public static final Object
NULL

A value indicating a null value - to be used as a placeholder where nulls are not allowed

public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> List<T>
asList(T... values)

public static <T> Set<T>
asSet(T... values)

public static <V extends Comparable<V>> NavigableSet<V>
asSortedSet(V... values)

public static <V extends Comparable<V>> NavigableSet<V>
asSortedSet(Collection<? extends V> values)

public static <
The element type
V
>
NavigableSet<V>

Returns:

A NavigableSet containing the values (if any) sorted using the provided comparator
asSortedSet
(Comparator<? super V>
The (non-null) Comparator to use
comp
,
V...
The values to be added (ignored if null)
values
)

public static <
The element type
V
>
NavigableSet<V>

Returns:

A NavigableSet containing the values (if any) sorted using the provided comparator
asSortedSet
(Comparator<? super V>
The (non-null) Comparator to use
comp
,
Collection<? extends V>
The values to be added (ignored if null/empty)
values
)

public static int

Returns:

Negative is 1st array comes first in lexicographical order, positive if 2nd array comes first and zero if equal
compare
(char[]
1st array
c1
,
char[]
2nd array
c2
)

Compares 2 character arrays - Note: null and empty are considered equal

public static <T> boolean
containsAny(Collection<? extends T> coll, Iterable<? extends T> values)

public static <
Generic base class
B
,
Generic child class
D extends B
>
Function<D, B>

Returns:

An identity Function that returns its input child class as a base class
downcast
()

public static <
Generic element type
T
>
boolean

Returns:

true if the following holds:
  • Same size - Note: null collections are consider equal to empty ones
  • First collection contains all elements of second one and vice versa
equals
(Collection<T>
First collection
c1
,
Collection<T>
Second collection
c2
)

public static List<String>
filterToNotBlank(final List<String> values)

public static <T> int
findFirstDifferentValueIndex(List<? extends T> c1, List<? extends T> c2)

public static <T> int
findFirstDifferentValueIndex(List<? extends T> c1, List<? extends T> c2, UnaryEquator<? super T> equator)

public static <T> int
findFirstDifferentValueIndex(Iterable<? extends T> c1, Iterable<? extends T> c2)

public static <T> int
findFirstDifferentValueIndex(Iterable<? extends T> c1, Iterable<? extends T> c2, UnaryEquator<? super T> equator)

public static <T> int
findFirstDifferentValueIndex(Iterator<? extends T> i1, Iterator<? extends T> i2)

public static <T> int
findFirstDifferentValueIndex(Iterator<? extends T> i1, Iterator<? extends T> i2, UnaryEquator<? super T> equator)

public static <T> T
findFirstMatchingMember(Predicate<? super T> acceptor, T... values)

public static <T> T
findFirstMatchingMember(Predicate<? super T> acceptor, Collection<? extends T> values)

public static <T> void
forEach(Iterable<? extends T> values, Consumer<? super T> consumer)

public static int

Returns:

The calculated hash code
hashCode
(String
The String value to calculate the hash code on - may be null/empty in which case a value of zero is returned
s
)

public static int

Returns:

The calculated hash code
hashCode
(String
The String value to calculate the hash code on - may be null/empty in which case a value of zero is returned
s
,
Boolean
Whether to convert the string to uppercase, lowercase or not at all:
useUppercase
)

public static <
Type of element
T
>
T

Returns:

first element by iteration or null if none available
head
(Iterable<? extends T>
The Iterable instance - ignored if null/empty
it
)

Returns the first element in iterable - it has some optimization for List-s Deque-s and SortedSets.

public static int
indexOf(CharSequence cs, char c)

public static boolean

Returns:

true if the CharSequence is null, empty or whitespace only
isBlank
(final CharSequence
the CharSequence to check, may be null
cs
)

Checks if a CharSequence is empty (""), null or whitespace only.

public static boolean
public static boolean
public static <T> boolean
isEmpty(Iterable<? extends T> iter)

public static <T> boolean
isEmpty(Iterator<? extends T> iter)

public static <T> boolean
isEmpty(T[] a)

public static boolean
isEmpty(char[] chars)

public static boolean

Returns:

true if the duration is negative or zero
isNegativeOrNull
(Duration
the duration
d
)

Check if a duration is negative or zero

public static boolean
public static boolean
public static boolean
public static <T> boolean
isNotEmpty(Iterable<? extends T> iter)

public static <T> boolean
isNotEmpty(Iterator<? extends T> iter)

public static boolean

Returns:

true if the duration is greater than zero
isPositive
(Duration
the duration
d
)

Check if a duration is positive

public static <
Type of value being iterated
T
>
Iterator<T>

Returns:

A non-null iterator which may be empty if no iterable instance or no iterator returned from it
iteratorOf
(Iterable<T>
The Iterable instance
iterable
)

Resolves to an always non-null iterator

public static <
Type of value being iterated
T
>
Iterator<T>

Returns:

A non-null iterator which may be empty if no iterator instance
iteratorOf
(Iterator<T>
The Iterator instance
iter
)

Resolves to an always non-null iterator

public static <T> String
join(T[] values, char ch)

public static String
join(Iterable<?> iter, char ch)

public static String
join(Iterator<?> iter, char ch)

public static <T> String
join(T[] values, CharSequence sep)

public static String
join(Iterable<?> iter, CharSequence sep)

public static String
join(Iterator<?> iter, CharSequence sep)

public static int
public static int
public static <T> int
length(T... a)

public static int
length(char[] chars)

public static <T, U> List<U>
map(Collection<? extends T> values, Function<? super T, ? extends U> mapper)

public static <T, U> NavigableSet<U>
mapSort(Collection<? extends T> values, Function<? super T, ? extends U> mapper, Comparator<? super U> comparator)

public static <
Generic type of supplied value
T
>
Supplier<T>

Returns:

The memoized Supplier
memoizeLock
(Supplier<? extends T>
The actual Supplier
delegate
)

The delegate Suppliers get() method is called exactly once and the result is cached.

public static <
Type of value being iterated
T
>
Iterable<T>

Returns:

The wrapping instance
multiIterableSuppliers
(Iterable<? extends Supplier<? extends Iterable<? extends T>>>
The providers - ignored if null (i.e., return an empty iterable instance)
providers
)

Wraps a group of Suppliers of Iterable instances into a "unified" Iterable of their values, in the same order as the suppliers - i.e., once the values from a specific supplier are exhausted, the next one is consulted, and so on, until all suppliers have been consulted

public static <E extends Enum<E>> Set<E>
of(E... values)

public static <E extends Enum<E>> Set<E>
of(Collection<? extends E> values)

public static String

Returns:

the text with any replacements processed
replace
(String
text to search and replace in
text
,
String
String to search for
repl
,
String
String to replace with
with
,
int
maximum number of values to replace, or -1 if no maximum
max
)

Replace a String with another String inside a larger String, for the first max values of the search String.

public static String
public static int
safeCompare(String s1, String s2, boolean caseSensitive)

public static <
The type of value being evaluated
T
>
List<T>

Returns:

A List of all the values that were accepted by the predicate
selectMatchingMembers
(Predicate<? super T>
The Predicate to consult whether a member is selected
acceptor
,
T...
The values to be scanned
values
)

Returns a list of all the values that were accepted by a predicate

public static <
The type of value being evaluated
T
>
List<T>

Returns:

A List of all the values that were accepted by the predicate
selectMatchingMembers
(Predicate<? super T>
The Predicate to consult whether a member is selected
acceptor
,
Collection<? extends T>
The values to be scanned
values
)

Returns a list of all the values that were accepted by a predicate

public static <
Generic return type
T
>
T

Returns:

The first value that matches the specified type - null if none found
selectNextMatchingValue
(Iterator<?>
The source values - ignored if null
values
,
Class<T>
The (never @code null) type of values to select - any value whose type is assignable to this type will be selected by the iterator.
type
)

public static int
public static String[]
split(String s, char ch)

public static <T> Stream<T>
stream(Iterable<T> values)

public static CharSequence

Returns:

If the sequence contains the delimiter on both ends, then it is are stripped, otherwise nothing is done
stripDelimiters
(CharSequence
The CharSequence to be checked
s
,
char
The expected delimiter
delim
)

public static CharSequence

Returns:

If the sequence contains any of the QUOTES on both ends, then they are stripped, otherwise nothing is done
stripQuotes
(CharSequence
The CharSequence to be checked
s
)

public static <
Type of value being supplied
T
>
Supplier<T>

Returns:

The supplier wrapper
supplierOf
(T
The value to be supplied
value
)

Wraps a value into a Supplier

public static <T> Collector<T, ?, NavigableSet<T>>
toSortedSet(Comparator<? super T> comparator)

public static String
public static <T> List<T>
unmodifiableList(T... values)

public static <T> List<T>
unmodifiableList(Collection<? extends T> values)

public static <T> List<T>
public static <U, V> Iterable<V>
wrapIterable(Iterable<? extends U> iter, Function<? super U, ? extends V> mapper)

public static <U, V> Iterator<V>
wrapIterator(Iterable<? extends U> iter, Function<? super U, ? extends V> mapper)

public static <U, V> Iterator<V>
wrapIterator(Iterator<? extends U> iter, Function<? super U, ? extends V> mapper)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait