public static final boolean[] | Singleton instance of an empty boolean array. |
public static final byte[] | Singleton instance of an empty byte array. |
public static final char[] | Singleton instance of an empty char array. |
public static final Class< | Singleton instance of an empty Class array. |
public static final double[] | Singleton instance of an empty double array. |
public static final float[] | Singleton instance of an empty float array. |
public static final int[] | Singleton instance of an empty int array. |
public static final long[] | Singleton instance of an empty long array. |
public static final Object[] | Singleton instance of an empty Object array. |
public static final short[] | Singleton instance of an empty short array. |
public static final StackTraceElement[] | Singleton instance of an empty StackTraceElement array. |
public static final String[] | Singleton instance of an empty String array. |
public static final Throwable[] | Singleton instance of an empty Throwable array. |
public static < | Adds all the elements in the argument iterable to the specified collecion. |
public static < | addAll( Adds all the elements in the argument collection to the specified collecion. |
public static < | Adds all the remaining elements in the argument iterator to the specified collecion. |
public static < | addAll( Adds all the elements in the specified iterable to the argument collecion. |
public static String | classNameOf( Gets the class name of the argument object. |
public static < | classOf( Gets the class of the argument if non- null . |
public static < | Gets the class of the argument if non- null , else returns a default value. |
public static Class< | classOfArrayElements( Gets the classes of the elements in the argument array. |
public static Class< | classOfArrayElements( Gets the classes of the elements in the argument array. |
public static < | Clones the argument object using the specified cloner function. |
public static < | cloneArray( Clones the argument array to the target component type using the specified cloner function. |
public static < | cloneArray( Clones the argument array using the specified cloner function. |
public static < | cloneArrayList( Clones the argument collection by creating an array list that contains the same items. |
public static < | cloneArrayList( Clones the argument collection and its elements into an array list. |
public static < | cloneEnumSet( Creates an EnumSet for the argument enum class and values. |
public static < | cloneHashMap( Clones the argument map by creating a hash map that contains the same entries. |
public static < | cloneLinkedHashMap( Clones the argument map by creating a linked hash map that contains the same entries. |
public static < | cloneLinkedHashSet( Clones the argument collection by creating a new LinkedHashSet. |
public static < | cloneTreeMap( Clones the argument map by creating a tree map that contains the same entries. |
public static < | cloneTreeMap( Clones the argument map and its entries into a tree map. |
public static < | cloneTreeMap( Clones the argument sorted map by creating a tree map with the same order and entries. |
public static < | cloneTreeSet( Clones the argument collection by creating an tree set that contains the same items. |
public static < | cloneTreeSet( Clones the argument sorted set by creating an tree set with the same order and items. |
public static < | collectionOrderedEquals( Same as calling collectionEquals (left, right, Objects::equals ). |
public static < | collectionOrderedEquals( Checks if the argument collections equal by checking the equality of the elements in iteration order using the
given function. |
public static String | collectionToString( Creates a string representation of the argument iterable. |
public static < | compareArrays( Comparison function for comparing the elements of arrays. |
public static < | compareIterables( Comparison function for comparing elements of iterables. |
public static < | compareIterators( Comparison function for comparing iterators. |
public static < | compareNullsFirst( Comparator function that sorts non- null arguments by natural order, else the null
values first. |
public static < | compareNullsLast( Comparator function that sorts non- null arguments by natural order, else the null
values last. |
public static < | compareOrderedMaps( Comparison function for comparing maps based on their iteration order and values. |
public static < | compareOrderedMaps( Comparison function for comparing sorted maps with the same ordering. |
public static < | compareOrderedSets( Comparison function for comparing sorted sets with the same ordering. |
public static boolean | Checks if the argument iterable contains the specified object. |
public static boolean | contains( Checks if the argument collection is non- null and contains the given object. |
public static boolean | containsAny( Checks if the argument haystack collection contains any element from the needle elements. |
public static boolean | containsAny( Checks if the argument haystack collection contains any element from the needle iterator. |
public static boolean | containsAnyKey( Checks if the argument haystack map contains any key from the needle elements. |
public static boolean | containsAnyValue( Checks if the argument haystack map contains any value from the needle elements. |
public static boolean | containsKey( Checks if the argument map contains a key for the given object. |
public static boolean | containsValue( Checks if the argument map contains a value for the given object. |
public static < | createConcurrentSkipListMapFromSortedIterator( Creates a ConcurrentSkipListMap based on the sorted entries in the argument iterator. |
public static < | createConcurrentSkipListMapFromSortedIterator( Creates a ConcurrentSkipListMap based on the sorted entries in the argument iterator. |
public static < | createConcurrentSkipListSetFromSortedIterator( Creates a ConcurrentSkipListSet based on the sorted elements in the argument iterator. |
public static < | createConcurrentSkipListSetFromSortedIterator( Creates a ConcurrentSkipListSet based on the sorted elements in the argument iterator. |
public static < | createImmutableNavigableMapFromSortedIterator( Creates an immutable NavigableMap based on the sorted entries in the argument iterator. |
public static < | createImmutableNavigableMapFromSortedIterator( Creates an immutable NavigableMap based on the sorted entries in the argument iterator. |
public static < | createTreeMapFromSortedIterator( Creates a TreeMap based on the sorted entries in the argument iterator. |
public static < | createTreeMapFromSortedIterator( Creates a TreeMap based on the sorted entries in the argument iterator. |
public static < | createTreeSetFromSortedIterator( Creates a TreeSet based on the sorted elements in the argument iterator. |
public static < | createTreeSetFromSortedIterator( Creates a TreeSet based on the sorted elements in the argument iterator. |
public static boolean | deepEquals( Function that checks the arguments for deep equality. |
public static boolean | defaultize( Checks if the argument boxed boolean is null and returns the default value if it is. |
public static byte | defaultize( Checks if the argument boxed byte is null and returns the default value if it is. |
public static char | defaultize( Checks if the argument boxed char is null and returns the default value if it is. |
public static double | defaultize( Checks if the argument boxed double is null and returns the default value if it is. |
public static float | defaultize( Checks if the argument boxed float is null and returns the default value if it is. |
public static int | defaultize( Checks if the argument boxed int is null and returns the default value if it is. |
public static long | defaultize( Checks if the argument boxed long is null and returns the default value if it is. |
public static short | defaultize( Checks if the argument boxed short is null and returns the default value if it is. |
public static boolean | equalsExcCheck( Checks if the argument objects equal. |
public static < | getComparator( Gets the comparator for a sorted map. |
public static < | getComparator( Gets the comparator for a sorted set. |
public static < | getContainsAny( Checks if the argument haystack collection contains any element from the needle elements, and returns it if
found. |
public static < | getEntry( Gets the entry in a navigable map that has the specified key. |
public static Class< | getEnumMapEnumType( Gets the enumeration type of the argument EnumMap. |
public static < | getExactKey( Gets the key that is present in the navigable map and equals to the specified key argument. |
public static < | getListElement( Gets the element of a list at the specified index. |
public static < | getMapValue( Gets the value mapped to the given key in a map, if the map is non- null . |
public static < | getMapValueOrDefault( Gets the value mapped to the given key in a map, or the default if the key is not present in the map or if the
map is non- null . |
public static < | getOptional( Gets the value of an optional if it is non- null , and is present. |
public static < | getReference( Gets the referenced object by the argument reference, if it is non- null . |
public static < | getSupplier( Gets the value from a supplier, if it is non- null . |
public static boolean | hasNonNull( Checks if there are any non- null values among the argument. |
public static boolean | hasNonNull( Checks if there are any non- null values among the argument. |
public static boolean | Checks if there are any null values among the argument. |
public static boolean | Checks if there are any null values among the argument. |
public static int | indexOfIterable( Finds the index of the first occurrence of a given object in an iterable. |
public static boolean | |
public static boolean | isNaturalOrder( Checks if the argument comparator represents the natural order. |
public static boolean | Checks if the argument character sequence is null or empty. |
public static boolean | isNullOrEmpty( Checks if the argument iterable is null or empty. |
public static boolean | isNullOrEmpty( Checks if the argument string is null or empty. |
public static boolean | isNullOrEmpty( Checks if the argument string is null or empty. |
public static boolean | isNullOrEmpty( Checks if the argument string is null or empty. |
public static boolean | isNullOrEmpty( Checks if the argument optional is null , or contains no value. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isNullOrEmpty( Checks if the argument array is null , or empty (i.e. |
public static boolean | isSameClass( Checks if the argument objects are an instance of the same class. |
public static < | isSorted( Checks if the argument iterable is sorted by the order specified by the given comparator. |
public static < | isSortedEntries( Checks if the keys of the argument entry iterable is sorted by the order specified by the given comparator. |
public static < | isStrictlySorted( Checks if the argument iterable is strictly sorted by the order specified by the given comparator. |
public static < | isStrictlySortedEntries( Checks if the keys of the argument entry iterable is strictly sorted by the order specified by the given
comparator. |
public static boolean | |
public static < | iterablesOrderedEquals( Same as calling iterablesEquals (left, right, Objects::equals ). |
public static < | iterablesOrderedEquals( Checks if the argument iterables equal by checking the equality of the elements in iteration order using the
given function. |
public static < | iterateOrderedEntryIterables( Iterates over the given iterables of map entries assuming that both of them are sorted by the specified
comparator. |
public static < | iterateOrderedEntryIterablesBreak( Iterates over the given iterables of map entries assuming that both of them are sorted by the specified
comparator, optionally breaking the iteration. |
public static < | iterateOrderedEntryIterablesDual( Iterates over the given iterables of map entries assuming that both of them are sorted by the specified
comparator, and calling the given action for paired entries only. |
public static < | iterateOrderedEntryIterablesDualBreak( Iterates over the given iterables of map entries assuming that both of them are sorted by the specified
comparator, and calling the given action for paired entries only, optionally breaking the iteration. |
public static < | iterateOrderedEntryIterators( Iterates over the given iterators of map entries assuming that both of them are sorted by the specified
comparator. |
public static < | iterateOrderedEntryIteratorsBreak( Iterates over the given iterators of map entries assuming that both of them are sorted by the specified
comparator, optionally breaking the iteration. |
public static < | iterateOrderedEntryIteratorsDual( Iterates over the given iterators of map entries assuming that both of them are sorted by the specified
comparator, and calling the given action for paired entries only. |
public static < | iterateOrderedEntryIteratorsDualBreak( Iterates over the given iterators of map entries assuming that both of them are sorted by the specified
comparator, calling the action only for matching entries, optionally breaking the iteration. |
public static < | iterateOrderedIterables( Iterates over the given iterables assuming that both of them are sorted by the natural order. |
public static < | iterateOrderedIterables( Iterates over the given iterables assuming that both of them are sorted by the specified comparator function. |
public static < | iterateOrderedIterators( Iterates over the given iterators assuming that both of them are sorted by the natural order. |
public static < | iterateOrderedIterators( Iterates over the given iterators assuming that both of them are sorted by the specified comparator function. |
public static boolean | iteratePrevUntil( Moves the argument iterator backwards until an object is encountered that equals the argument. |
public static < | iterateSortedMapEntries( Iterates over the entries of the argument sorted maps assuming that both of them are sorted by the same order. |
public static < | iterateSortedMapEntriesBreak( Iterates over the entries of the argument sorted maps assuming that both of them are sorted by the same order,
optionally breaking the iteration. |
public static < | iterateSortedMapEntriesDual( Iterates over the entries of the argument sorted maps assuming that both of them are sorted by the same order,
and calling the given action for paired entries only. |
public static < | iterateSortedMapEntriesDualBreak( Iterates over the entries of the argument sorted maps assuming that both of them are sorted by the same order,
and calling the given action for paired entries only, optionally breaking the iteration. |
public static boolean | iterateUntil( Moves the argument iterator until an object is encountered that equals the argument. |
public static < | Calls Iterable.iterator() on the argument if non- null . |
public static < | iterator( Gets an iterator that iterates over the argument array. |
public static int | Calculates the hash of the elements contained in the argument based on the method specified by
List.hashCode(). |
public static int | Calculates the hash of the elements contained in the argument based on the method specified by
List.hashCode(). |
public static boolean | listsEqual( Checks the argument lists for equality. |
public static int | mapEntryHash( Calculates the hash of the argument key-value map entry based on the method specified by
Map.Entry.hashCode(). |
public static int | mapEntryHash( Calculates the hash of the argument map entry based on the method specified by Map.Entry.hashCode(). |
public static int | Calculates the hash of the entries contained in the argument based on the method specified by
Map.hashCode(). |
public static int | Calculates the hash of the entries contained in the argument based on the method specified by
Map.hashCode(). |
public static int | Calculates the hash of the entries contained in the argument based on the method specified by
Map.hashCode(). |
public static < | mapOrderedEquals( Same as calling orderedMapEquals (left, right, Objects::equals ). |
public static < | mapOrderedEquals( Checks if the argument maps equal by checking the equality of the keys and values in iteration order using the
given function. |
public static String | mapToString( Creates a string representation of the argument map. |
public static boolean | Checks the argument maps for equality. |
public static < | newArrayList( Creates a new array list and adds each element of the argument iterable. |
public static < | newArrayList( Creates a new array list and adds each element of the argument collection. |
public static < | newArrayList( Creates a new array list and adds the elements of the first, and then the second collection. |
public static < | newArrayList( Creates a new array list and adds each remaining element from the argument iterator. |
public static < | newArrayList( Creates a new array list and adds each element of the argument array. |
public static < | newHashMap( Creates a new HashMap and initializes it with the argument objects. |
public static < | newHashSet( Creates a new HashSet and initializes it with the argument objects. |
public static < | newHashSet( Creates a new HashSet and initializes it with the argument objects. |
public static < | newHashSet( Creates a new HashSet and initializes it with the argument objects. |
public static < | newIdentityHashMap( Creates a new IdentityHashMap and initializes it with the argument objects. |
public static < | Creates a new identity hash set. |
public static < | newIdentityHashSet( Creates a new identity hash set and initializes it with the argument objects. |
public static < | newIdentityHashSet( Creates a new identity hash set and initializes it with the argument objects. |
public static < | newIdentityHashSet( Creates a new identity hash set and initializes it with the argument objects. |
public static < | newIdentityHashSet( Creates a new identity hash set and initializes it with the argument objects. |
public static < | newLinkedHashMap( Creates a new LinkedHashMap and initializes it with the argument objects. |
public static < | newLinkedHashSet( Creates a new LinkedHashSet and initializes it with the argument objects. |
public static < | newLinkedHashSet( Creates a new LinkedHashSet and initializes it with the argument objects. |
public static < | newLinkedHashSet( Creates a new LinkedHashSet and initializes it with the argument objects. |
public static < | newSetFromMap( Creates a new set that is backed by the argument map. |
public static < | newTreeMap( Creates a new TreeMap and initializes it with the argument map entries. |
public static < | newTreeMap( Creates a new TreeMap and initializes it with the argument map entries. |
public static < | newTreeSet( Creates a new TreeSet and initializes it with the argument objects. |
public static < | newTreeSet( Creates a new TreeSet and initializes it with the argument objects. |
public static < | newTreeSet( Creates a new TreeSet and initializes it with the argument objects. |
public static < | newTreeSet( Creates a new TreeSet and initializes it with the argument objects. |
public static int | nonNullObjectCount( Counts the number of non- null objects in the argument iterable. |
public static int | nonNullObjectCount( Counts the number of non- null objects in the argument array. |
public static < | nullDefault( Checks if the first argument is null and if it is, returns the default value. |
public static < | nullDefault( Checks if the first argument is null and if it is, returns the value supplied by the default
supplier. |
public static int | nullObjectCount( Counts the number of null objects in the argument iterable. |
public static int | nullObjectCount( Counts the number of null objects in the argument array. |
public static < | objectsEquals( Checks the argument objects for equality using the given comparator predicate. |
public static < | onceIterable( Converts the argument iterator to an once iterable. |
public static void | Backports Reference .reachabilityFence(Object) to Java 8. |
public static boolean | removeAtIndex( Finds the object at the given index in the argument iterable, and removes it. |
public static < | removeFirstElement( Removes the first element from an iterable if present. |
public static < | removeFirstElementThrow( Removes the first element from an iterable, or throws an exception if there is no first element. |
public static boolean | removeFirstOccurrence( Searches for the first occurrence of an object in an iterable, and removes it. |
public static < | requireComparator( Validation method for requiring that the argument sorted map is sorted by the given comparator. |
public static < | requireComparator( Validation method for requiring that the argument sorted set is sorted by the given comparator. |
public static < | requireNaturalOrder( Validation method for checking if the comparator represents the natural order. |
public static < | requireNaturalOrder( Validation method for checking if a sorted map is ordered by the natural order. |
public static < | requireNaturalOrder( Validation method for checking if a sorted set is ordered by the natural order. |
public static < | requireNonNullElements( Validation method for requiring that the argument iterable contains no null elements. |
public static < | requireNonNullElements( Validation method for requiring that the argument array contains no null elements. |
public static < | requireNonNullEntryKeyValues( Validation method for requiring that the argument map contains no null keys or values. |
public static < | requireNonNullValues( Validation method for requiring that the argument map contains no null values. |
public static < | requireSameComparators( Validation method for ensuring that the two comparators define the same order. |
public static < | requireSameComparators( Validation method for ensuring that two sorted maps have the same order. |
public static < | requireSameComparators( Validation method for ensuring that two sorted sets have the same order. |
public static < | reversedList( Gets a reversed view of the argument list. |
public static int | Calculates the hash of the elements contained in the argument based on the method specified by
Set.hashCode(). |
public static int | Calculates the hash of the elements contained in the argument based on the method specified by
Set.hashCode(). |
public static boolean | Checks the argument sets for equality. |
public static < | singleValueMap( Creates a new navigable map view that has the same keys as the argument set, and all keys are mapped to the
argument value. |
public static < | singleValueMap( Creates a new map view that has the same keys as the argument set, and all keys are mapped to the argument value. |
public static < | singleValueMap( Creates a new sorted map view that has the same keys as the argument set, and all keys are mapped to the argument
value. |
public static int | sizeOfIterable( Counts the number of elements in the iterable. |
public static int | sizeOfIterator( Counts the number of remaining elements in the iterator. |
public static RuntimeException | Sneakily throws the argument throwable. |
public static < | transformArray( Transforms the elements of the given array using the transformer function. |
public static < | transformIterable( Wraps the argument iterable into a new one that creates iterators which transform the elements using the given
function. |
public static < | transformIterator( Wraps the argument iterator into a new one that transforms the elements using the given function. |
boolean
array.byte
array.char
array.double
array.float
array.int
array.long
array.short
array.
If the argument iterable is null
, no elements are added to the collection.
null
. (May be only thrown when the iterable is
non-null
.)
If the argument collection is null
, no elements are added to the target collection.
null
. (May be only thrown when the source collection is
non-null
and non-empty.)
If the argument iterator is null
, no elements are added to the collection.
null
. (May be only thrown when the iterator is
non-null
.)
If the argument array is null
, no elements are added to the collection.
null
. (May be only thrown when the array is non-null
and non-empty.)
If the argument is null
, null
is returned.
null
if the object is null
.null
.null
if the object is null
.null
, else returns a default value.null
.null
.
This method will determine the class type of each element in the argument in the same manner as
classOf(
null
if
the array is null
.
This method will determine the class type of each element in the argument in the same manner as
classOf(
null
.null
if
the array is null
.
This method returns null
, if the argument object is null
, else calls the cloner
function with its as the argument.
null
object.null
if the object was null
, or the cloner function
returned null
.null
.
This method returns null
if the argument array is null
, else calls the cloner function
for each element in the source array and puts them into a new array with the specified component type.
null
if the object was null
.null
.
This method returns null
if the argument array is null
, else calls the cloner function
for each element in the source array and puts them into a new array.
null
if the object was null
.null
.
This method returns null
, if the argument is null
.
This method returns null
, if the argument is null
.
A new ArrayList will be created, and the element cloner function will be applied to each element in the original collection. The cloned elements will be added to the new list.
null
.This method can be useful when creating a clone of collections that contain enumeration values.
The enumeration class argument is required for proper operation, as in order to construct an EnumSet, the enum class is required. If the argument collection is empty, this would not be available.
null
if the argument collection is null
.
This method returns null
, if the argument is null
.
This method returns null
, if the argument is null
.
The LinkedHashSet is initialized using the LinkedHashSet(Collection<E>) constructor.
This method returns null
, if the argument is null
.
This method returns null
, if the argument is null
.
A new TreeMap will be created, and the key and value cloner functions will be applied to each entry in the original map. The cloned entries will be put into the new map.
null
.
This method returns null
, if the argument is null
.
This method returns null
, if the argument is null
.
This method returns null
, if the argument is null
.
(left, right, Objects::equals
).true
if the collections are considered to be equal.Note: this method is not suitable for checking the equality of unordered collections like HashSet.
If the collections have different sizes, this method will return false
.
The method handles nullability of the arguments.
This method differs from iterablesOrderedEquals(
Example usage:
ObjectUtils.collectionEquals(coll1, coll2, Objects::equals);
true
if the collections are considered to be equal.null
.
Each element in the argument will be displayed in a comma separated list between square brackets.
([]
)
The method creates a string representation of the iterable that is semantically same as the usual collection representations.
This function will iterate over the elements of the argument arrays and compare them after each other. Each element is going to be compared to the element at the same index in the other array.
The argument comparator works the same way as Comparator, but takes elements with different types as
argument. If the comparator is null
, the elements are compared by the
natural order of theirs.
The comparison function finishes early, if it finds non-equal elements, in which case the function will return the result of the first mismatching elements.
If all checked elements are equal, then the shorter arrays will be ordered first if they have different lengths.
The method will only check elements up to the length of the shorter array.
null
.
Works the same ways as compareIterators(
Same as:
compareIterators(comparables1.iterator(), comparables2.iterator(), comparator);
null
.This function will iterate over both iterators simultaneously and compare each pair of elements accordingly.
The argument comparator works the same way as Comparator, but takes elements with different types as
argument. If the comparator is null
, the elements are compared by the
natural order of theirs.
If a mismatching element is found, the result of that comparison is returned from the function.
If one of the iterator has no more elements, that iterator will be ordered first. I.e. the shorter iterators are ordered first.
If neither iterators have next elements after all comparisons, 0 is returned.
null
.null
arguments by natural order, else the null
values first.null
arguments by natural order, else the null
values last.Note: this method is not suitable for comparing unordered maps like HashMap.
This method will iterate over the arguments maps and compare the keys of their entries. If the key comparison yields a non-zero result, it is returned as the comparion result of the function. If the keys compare to be equal, the values of the maps are compared using the value comparator argument. If the value comparions yields non-zero result, it is returned as the result of the function. If they equal, the next entry will be processed the same way.
When there are no more entries in either of the maps, the one that has less entries will be ordered first. If both maps have the same length, and all of their entries compare to be equal, this function will return 0 as the comparison result.
This method is suitable for comparing maps only, if the maps have a deterministic iteration order. It is most suitable for sorted maps (E.g. TreeMap) or maps that have a predictable iteration order (E.g. LinkedHashMap).
null
.
This function works the same way as compareOrderedMaps(
null
.
This function works the same way as compareIterables(
null
.
This method iterates over the iterable and searches for the specified object. Object.equals(
true
if the iterable is non-null
and the object was found.null
and contains the given object.
This method checks if the collection is non-null
, and if so, calls
Collection.contains(
The method will iterate over the needle objects and check if it is contained in the argument haystack. If the
needle is found, true
is returned.
If the haystack argument is null
, false
is returned.
true
if a needle object was found.null
.
The method will iterate over the needle iterator and check if it an element is contained in the argument
haystack. If the needle is found, true
is returned.
If the haystack argument is null
, false
is returned.
true
if a needle object was found.null
.
If the haystack argument is null
, false
is returned.
true
if any needle element is present as a key in the haystack map.null
.
If the haystack argument is null
, false
is returned.
true
if any needle element is present as a value in the haystack map.null
.true
if the map is non-null
and contains a key for the object.true
if the map is non-null
and contains a value for the object.The entries iterated by the iterator must be stricly ordered by natural order.
The above requirement is not checked by this function. Violating it will result in the returned map not working properly.
Same as:
createConcurrentSkipListMapFromSortedIterator(it, null);
null
.The entries iterated by the iterator must be stricly ordered by the argument comparator.
The above requirement is not checked by this function. Violating it will result in the returned map not working properly.
null
to use the natural order.null
.The elements iterated by the iterator must be stricly ordered by natural order.
The above requirements are not checked by this function. Violating the above requirements will result in the returned set not working properly.
Same as:
createConcurrentSkipListSetFromSortedIterator(it, null);
null
.The elements iterated by the iterator must be stricly ordered by the argument comparator.
The above requirements are not checked by this function. Violating the above requirements will result in the returned set not working properly.
null
to use the natural order.null
.The entries iterated by the iterator must be stricly ordered by natural order.
The number of entries iterated over must be the same as the size
argument.
The above requirements are not checked by this function. Violating the above requirements will result in the returned map not working properly.
Same as:
createTreeMapFromSortedIterator(it, size, null);
null
.The entries iterated by the iterator must be stricly ordered by the argument comparator.
The number of entries iterated over must be the same as the size
argument.
The above requirements are not checked by this function. Violating the above requirements will result in the returned map not working properly.
null
to use the natural order.null
.The elements iterated by the iterator must be stricly ordered by natural order.
The number of elements iterated over must be the same as the size
argument.
The above requirements are not checked by this function. Violating the above requirements will result in the returned set not working properly.
Same as:
createTreeSetFromSortedIterator(it, size, null);
null
.The elements iterated by the iterator must be stricly ordered by the argument comparator.
The number of elements iterated over must be the same as the size
argument.
The above requirements are not checked by this function. Violating the above requirements will result in the returned set not working properly.
null
to use the natural order.null
.
If at least one argument is not an array, then they will be simply compared using Object.equals(
When both arguments are arrays, they will be checked for deep equality for each of their elements. This method handles if the arrays have primitive component types. If they have reference component types then each of the elements will be compared by deep equality accordingly.
This method works similarly to Arrays.deepEquals(
true
if the two objects equal.boolean
is null
and returns the default value if it is.boolean
.null
.null
, else the default argument.byte
is null
and returns the default value if it is.byte
.null
.null
, else the default argument.char
is null
and returns the default value if it is.char
.null
.null
, else the default argument.double
is null
and returns the default value if it is.double
.null
.null
, else the default argument.float
is null
and returns the default value if it is.float
.null
.null
, else the default argument.int
is null
and returns the default value if it is.int
.null
.null
, else the default argument.long
is null
and returns the default value if it is.long
.null
.null
, else the default argument.short
is null
and returns the default value if it is.short
.null
.null
, else the default argument.
If the Object.equals(false
is returned.
true
if the objects equal and no exception was thrown.
If the map is sorted by natural order (i.e. SortedMap.comparator() returns null
),
Comparator.naturalOrder() is returned.
null
.
If the set is sorted by natural order (i.e. SortedSet.comparator() returns null
),
Comparator.naturalOrder() is returned.
null
.The method will iterate over the needle objects and check if it is contained in the argument haystack. If the needle is found, it is returned.
If no needles are found, null
is returned. Note that if any needle object is null
, a
return value of null
can mean either that it was found or that it was not.
If the haystack argument is null
, null
is returned.
null
if none was found.null
.The method will retrieve the first key of the map and return the enum class of it. The method handles if the enum key is an anonymous inner class, and returns the enclosing enumeration type appropriately.
If the argument map is empty, the method will attempt to serialize the argument map to an ObjectOutputStream. It will intercept the type serialization and will return the found enum type. It is strongly recommended that the argument has the type EnumMap, and is not a subclass of it. This method is somewhat a hack, but no EnumMap implementation has failed with it yet, and is not expected to. If the enum type fails to be detected, an UnsupportedOperationException is thrown.
null
if the argument is null
.
If the list is null
, or the index is out of range, null
is returned.
If the list is concurrently modified while this method is called, the possible IndexOutOfBoundsException is relayed to the caller. (This is usually not an issue.)
null
if there's none.null
.
This method simply calls Map.get(null
.
null
if the map is null
, no mapping is present,
or the key is mapped to null
.null
.
This method simply calls Map.getOrDefault(null
. If it's
null
, the default value is returned.
null
or no mapping is
present.null
, and is present.null
if it is not present, or the optional is
null
.null
values among the argument.
If the argument iterable is null
, false
is returned.
true
if there's at least one non-null
element in the argument.null
values among the argument.
If the argument array is null
, false
is returned.
true
if there's at least one non-null
element in the argument.null
values among the argument.
If the argument iterable is null
, false
is returned.
true
if there's at least one null
element in the argument.null
values among the argument.
If the argument array is null
, false
is returned.
true
if there's at least one null
element in the argument.
The object will be compared using Object.equals(
null
.true
if the argument is the false
boolean.null
or empty. The emptiness is determined using the length of the sequence.
true
if the argument is null
or empty.null
or empty. This method includes creating an iterator for the given iterable.
true
if the argument is null
or empty.null
or empty.true
if the argument is null
or empty.null
, or contains no value.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.null
, or empty (i.e. has a length of 0).true
if the argument is null
or empty.The class of the arguments will be retrieved, and compared for equality.
If both of the arguments are null
, true
will be returned. If only one of the arguments
are null
, false is returned.
true
if they are an instance of the same class.
If the comparator is null
, the natural order is checked.
This method checks for weak ordering, meaning that if two consecutive elements compare to be equal, the iterable is still considered to be sorted.
true
if the elements in the iterable are sorted.
If the comparator is null
, the natural order is checked.
This method checks for weak ordering, meaning that if two consecutive keys compare to be equal, the iterable is still considered to be sorted.
true
if the keys in the entry iterable are sorted.
If the comparator is null
, the natural order is checked.
This method checks for strict ordering, meaning that if two consecutive elements compare to be equal, the iterable is not considered to be sorted.
true
if the elements in the iterable are strictly sorted.
If the comparator is null
, the natural order is checked.
This method checks for strict ordering, meaning that if two consecutive keys compare to be equal, the iterable is not considered to be sorted.
true
if the keys in the entry iterable are stricly sorted.true
if the argument is the true
boolean.(left, right, Objects::equals
).true
if the iterables are considered to be equal.Note: this method is not suitable for checking the equality of unordered collections like HashSet.
If the iterables have different sizes, this method will return false
.
The method handles nullability of the arguments.
Example usage:
ObjectUtils.collectionEquals(iterable1, iterable2, Objects::equals);
true
if the iterables are considered to be equal.null
.
Works the same way as iterateOrderedEntryIteratorsBreak(
null
.
Works the same way as iterateOrderedEntryIteratorsBreak(
false
from it to break the iteration.true
if the iterables were fully iterated over, false
if the action returned
false
for any invocation.null
.
Works the same way as
iterateOrderedEntryIteratorsDualBreak(
null
.
Works the same way as
iterateOrderedEntryIteratorsDualBreak(
false
from it to break the iteration.true
if the iterables were fully iterated over, false
if the action returned
false
for any invocation.null
.
Works the same way as iterateOrderedEntryIteratorsBreak(
null
.This method advances the argument iterator simultaneously in the order defined by the argument comparator function, and will pair the matching entries in the iterators.
During iteration, each entry key is compared to the current key of the other iterator. Based on the comparison result, the function will advance the iterator that returned the key that is less than the other. If the comparison resulted in equality, both iterators are advanecd.
The action argument will be called for each entry in the iterators. If a matching pair was not found for an entry
in an iterator, null
will be passed as the value argument for the action for the respective
parameter. When a match is found, both value arguments are present for the associated iterator. Note that a
null
argument for a value doesn't necessarily mean that the entry is not present in the other
iterator, but only that the associated value for the given key is null
for that entry. Callers
should ensure that the entries doesn't contain null
values if this can cause disruption.
If an iterator finishes early, the remaining entries will be iterated over in the other iterator, and the actions will be called.
For proper operation, the caller must ensure that the entries in both iterators are sorted by the the specified order. If this requirement is violated, the pairing algorithm will not work, however, all the iterators will still be fully iterated, and the action will be called for all entries, but the calls will be semantically incorrect. This function doesn't ensure that the iterators are ordered, and no runtime exception will be thrown if this requirement is violated.
The first argument of the passed action will be the key that is associated with the second and third arguments. The second argument is the value that was found in the left iterator, and the third is the value that was found in the right iterator.
true
if the iterators were fully iterated over, false
if the action returned
false
for any invocation.null
.
Works the same way as
iterateOrderedEntryIteratorsDualBreak(
null
.This method advances the argument iterator simultaneously in the order defined by the argument comparator function, and will pair the matching entries in the iterators.
During iteration, each entry key is compared to the current key of the other iterator. Based on the comparison result, the function will advance the iterator that returned the key that is less than the other. If the comparison resulted in equality, both iterators are advanecd.
The action argument will be called for each matched entry in the iterators. If a matching pair was not
found for an entry in an iterator, the action is not called. When a match is found, both value arguments are
present for the associated iterator. A null
argument in the action means that the associated value
for the entry was null
.
If an iterator finishes early, the remaining entries are not iterated over.
For proper operation, the caller must ensure that the entries in both iterators are sorted by the the specified order. If this requirement is violated, the pairing algorithm will not work, and actions will most likely not called appropriately.
The first argument of the passed action will be the key that is associated with the second and third arguments. The second argument is the value that was found in the left iterator, and the third is the value that was found in the right iterator.
This method works similarly to
iterateOrderedEntryIteratorsBreak(
true
if the iterators were fully iterated over, false
if the action returned
false
for any invocation.null
.This function will iterate both iterables simultaneously in ascending natural order, and will pair the matching elements in the iterables.
During iteration, each element is compared to the current element of the other iterator. Based on the comparison result, the function will advance the iterator that returned the element that compared to be less than the other. If the comparison resulted in equality, both iterators are advanced.
The action argument will be called for each element in the iterables. If a matching pair was not found for an
element in an iterable, null
will be passed as the argument for the action for the respective
parameter. When a match is found, both arguments are present for the associated iterable.
If an iterator finishes early, the remaining elements will be iterated over in the other iterator, and the actions will be called.
For proper operation, the caller must ensure that the elements in both iterables are sorted by the natural order. If this requirement is violated, the pairing algorithm will not work, however, all the iterables will still be fully iterated, and the action will be called for all elements, but the calls will be semantically incorrect. This function doesn't ensure that the iterables are ordered, and no runtime exception will be thrown if this requirement is violated.
null
.This function will iterate both iterables simultaneously in the order defined by the argument comparator function, and will pair the matching elements in the iterables.
During iteration, each element is compared to the current element of the other iterator. Based on the comparison result, the function will advance the iterator that returned the element that compared to be less than the other. If the comparison resulted in equality, both iterators are advanced.
The action argument will be called for each element in the iterables. If a matching pair was not found for an
element in an iterable, null
will be passed as the argument for the action for the respective
parameter. When a match is found, both arguments are present for the associated iterable.
If an iterator finishes early, the remaining elements will be iterated over in the other iterator, and the actions will be called.
For proper operation, the caller must ensure that the elements in both iterables are sorted by the specified order. If this requirement is violated, the pairing algorithm will not work, however, all the iterables will still be fully iterated, and the action will be called for all elements, but the calls will be semantically incorrect. This function doesn't ensure that the iterables are ordered, and no runtime exception will be thrown if this requirement is violated.
null
.This function will advance both iterators simultaneously in ascending natural order, and will pair the matching elements in the iterators.
During iteration, each element is compared to the current element of the other iterator. Based on the comparison result, the function will advance the iterator that returned the element that compared to be less than the other. If the comparison resulted in equality, both iterators are advanced.
The action argument will be called for each element in the iterators. If a matching pair was not found for an
element in an iterator, null
will be passed as the argument for the action for the respective
parameter. When a match is found, both arguments are present for the associated iterator.
If an iterator finishes early, the remaining elements will be iterated over in the other iterator, and the actions will be called.
For proper operation, the caller must ensure that the elements in both iterators are sorted by the natural order. If this requirement is violated, the pairing algorithm will not work, however, all the iterators will still be fully iterated, and the action will be called for all elements, but the calls will be semantically incorrect. This function doesn't ensure that the iterators are ordered, and no runtime exception will be thrown if this requirement is violated.
null
.This function will advance both iterators simultaneously in the order defined by the argument comparator function, and will pair the matching elements in the iterators.
During iteration, each element is compared to the current element of the other iterator. Based on the comparison result, the function will advance the iterator that returned the element that compared to be less than the other. If the comparison resulted in equality, both iterators are advanced.
The action argument will be called for each element in the iterators. If a matching pair was not found for an
element in an iterator, null
will be passed as the argument for the action for the respective
parameter. When a match is found, both arguments are present for the associated iterator.
If an iterator finishes early, the remaining elements will be iterated over in the other iterator, and the actions will be called.
For proper operation, the caller must ensure that the elements in both iterators are sorted by the the specified order. If this requirement is violated, the pairing algorithm will not work, however, all the iterators will still be fully iterated, and the action will be called for all elements, but the calls will be semantically incorrect. This function doesn't ensure that the iterators are ordered, and no runtime exception will be thrown if this requirement is violated.
null
.
If this method returns true
, the iterator will point before the object has been encountered. Calling
Iterator.remove() will remove an object that equals to the given argument.
This method works the same way as iterateUntil(
true
if an object was found that equals to the argument.null
.
Works the same way ax iterateOrderedEntryIterables(
If the maps are not ordered the same way, an IllegalArgumentException is thrown.
null
.
Works the same way ax iterateOrderedEntryIterablesBreak(
If the maps are not ordered the same way, an IllegalArgumentException is thrown.
false
from it to break the iteration.true
if the maps were fully iterated over, false
if the action returned
false
for any invocation.null
.
Works the same way ax iterateOrderedEntryIterablesDual(
If the maps are not ordered the same way, an IllegalArgumentException is thrown.
null
.
Works the same way ax
iterateOrderedEntryIterablesDualBreak(
If the maps are not ordered the same way, an IllegalArgumentException is thrown.
false
from it to break the
iteration.null
.
If this method returns true
, the iterator will point after the object has been encountered. Calling
Iterator.remove() will remove an object that equals to the given argument.
true
if an object was found that equals to the argument.null
.null
.null
if the argument is null
.null
if the argument is null
.null
.null
.This method will examine if both lists have the same size and their elements at the same indexes are equal.
Note: this method doesn't call List.size() to shortcut the equality check, but iterate over the lists at the same time.
true
if they equal.null
.null
.null
.null
.(left, right, Objects::equals
).true
if the maps are considered to be equal.Note: this method is not suitable for checking the equality of unordered maps like HashMap.
This method will simultaneously iterate over the entries of both maps and compare them for equality. This method is only suitable for checking equality of maps which iterate over the entries in a deterministic order. Examples for this are sorted maps (E.g. TreeMap), or maps that preserve their order in some ways (E.g. LinkedHashMap).
If the maps have different sizes, this method will return false
.
The method handles nullability of the arguments.
The method checks the sizes of the maps before starting the iteration, so callers should keep this in mind when passing arguments that provide a Map.size() method which has greater complexity than O(1) (E.g. some concurrent maps).
Example usage:
ObjectUtils.orderedMapEquals(map1, map2, Objects::equals);
true
if the maps are considered to be equal.null
.
Each entry in the map will be displayed in a comma separated list between curly braces. ({}
)
The method creates a string representation of the map that is semantically same as the usual map representations.
This method checks if the arguments have the same size, and each key in the first map is mapped to the same value in the second as in the first.
The method handles nullability of the arguments. If both of the arguments are null
,
true
is returned.
true
if they equal.
If the argument iterable is null
, no elements are added.
If the argument collection is null
, no elements are added.
If any of the collections is null
, no elements are added for them.
If the argument iterator is null
, no elements are added.
If the argument collection is null
, no elements are added.
If the argument is null
, the returned map will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned map will be empty.
The identity hash set is created by calling newSetFromMap(
If the argument is null
, the returned set will be empty.
The identity hash set is created by calling newSetFromMap(
If the argument is null
, the returned set will be empty.
The identity hash set is created by calling newSetFromMap(
If the argument is null
, the returned set will be empty.
The identity hash set is created by calling newSetFromMap(
If the argument is null
, the returned set will be empty.
The identity hash set is created by calling newSetFromMap(
If the argument is null
, the returned map will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
This method creates a set the same way as Collections.newSetFromMap(
null
if the argument map is null
.
If the argument is null
, the returned map will be empty.
If the argument is null
, the returned map will be empty.
The returned tree set will have the same ordering as the argument sorted map.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
If the argument is null
, the returned set will be empty.
The returned tree set will have the same ordering as the argument sorted set.
If the argument is null
, the returned set will be empty.
null
objects in the argument iterable.
If the argument itself is null
, 0 is returned.
null
elements found.null
objects in the argument array.
If the argument itself is null
, 0 is returned.
null
elements found.null
and if it is, returns the default value.null
.null
, else the default value.null
and if it is, returns the value supplied by the default
supplier.null
value for.null
.null
, else the computed value by the supplier.null
objects in the argument iterable.
If the argument itself is null
, 0 is returned.
null
elements found.null
objects in the argument array.
If the argument itself is null
, 0 is returned.
null
elements found.
If the objects are same by identity, true
is returned without calling the comparator.
If any of the objects are null
(and the other is not null
), then false
is
returned.
Else, the comparator predicate will be called with the arguments.
true
if the objects are same by identity, or the comparator returned true
.The Iterable.iterator() function of the returned iterable can only be called once, else IllegalStateException will be thrown. The returned iterator will be the same as the argument to this method.
null
.
This method will iterate over the argument iterable until the element at the given index is reached. Then it will
call Iterator.remove() and return true
.
If the specified index is greater than the number of objects in the iterable, no elements will be removed, and
false
is returned.
true
if the element at the index was removed.null
.This method will use Iterator.hasNext() to determine if there is an element in the iterable, and remove it if there is one.
null
if there was no such element. (null
will be
returned even if the first element is null
.)null
.This method will not call the Iterator.hasNext() method, and relies on the iterator to throw a NoSuchElementException if there is no first element. As per the documentation of the Iterator class, all of them should obey this behaviour.
null
.
This method will iterate over the argument iterable, and find the first occurrence in it, that equals to the
argument object. If found, Iterator.remove() is called to remove it, and true
is returned.
null
.true
if an element was removed.null
.
The comparators of the map and the argument are compared by equality. If the comparator instances doesn't
implement Object.equals(
null
to require the natural order.null
.
The comparators of the set and the argument are compared by equality. If the comparator instances doesn't
implement Object.equals(
null
to require the natural order.null
.null
.null
.null
elements.null
.null
elements.null
.null
keys or values.null
.null
values. The keys of the map is not examined.
null
.
The comparators of are compared by equality. null
arguments are treated as to denote the
natural order.
null
.The comparators of the sorted maps are compared by equality.
null
.null
.The comparators of the sorted sets are compared by equality.
null
.null
.The returned list is modifiable, and will return the elements in the reverse order as the argument. Any modifications made to the returned list will be propagated accordingly to the original list.
Calling this with a list that was reversed with this method, will return the original list. The following is
true
:
ObjectUtils.reversed(list) == ObjectUtils.reversed(ObjectUtils.reversed(list))
null
if the argument was null
.null
.null
.This method checks if the arguments have the same size, and the first set contains all elements from the second set.
The method handles nullability of the arguments. If both of the arguments are null
,
true
is returned.
true
if they equal.The returned map is partially modifiable, meaning that only some modifications will succeed. Removals are guaranteed to work, but insertions into the map may fail in some cases. Callers shouldn't rely on the put operations to work.
Putting a key-pair into the map may only work if the newly added entry value is identically the same as the mapped single value.
The Map.Entry.setValue(
null
.The returned map is partially modifiable, meaning that only some modifications will succeed. Removals are guaranteed to work, but insertions into the map may fail in some cases. Callers shouldn't rely on the put operations to work.
Putting a key-pair into the map may only work if the newly added entry value is identically the same as the mapped single value.
The Map.Entry.setValue(
null
.
The value of the elements are not examined, null
elements also count towards the result.
null
.
The value of the elements are not examined, null
elements also count towards the result.
null
.This method can be used to throw checked exceptions in a function context that doesn't declare it. In general, this functionality should be very rarely used, and one should not create an API that sneakily throws exceptions, as callers cannot catch them by explicitly declaring it.
A good use-case for this:
private Object calculate(Object k) throws IOException { return something; } public Object computeSomething(Object key) { try { return map.computeIfAbsent(key, k -> { try { return calculate(k); } catch (IOException e) { throw ObjectUtils.sneakyThrow(e); } }); } catch (IOException e) { // the exception sneakily thrown by the computer function is caught by ourself. return null; } }In the above example, we throw the IOException sneakily, and catch it in the enclosing code block. This is necessary, as the computer function doesn't allow for a checked exception to be thrown. In this case we deem that it is acceptable to use sneaky throwing, but callers should make sure that they catch the exception as well.
It is a good practice, that if a code sneakily throws some exception, the maintainer of the enclosing code should either explicitly catch the sneakily thrown exception, or declare it in the API method declaration.
Throwing the return value of the sneakyThrow(
This method will call the transformer function for each element in the array, and replace them with the result of the function.
If the argument array is null
, this method returns null
.
null
.The returned iterable will create iterators that transform each element using the given function.
If the transformer is null
, a NullPointerException might be thrown when an iterator is
constructed from the result.
null
if the iterable is null
.The returned iterator will use the argument function to transform each element, and return the resulting object.
null
if the iterator is null
.null
and the transformer is null
.