Package com.google.common.truth
Class SubjectUtils
java.lang.Object
com.google.common.truth.SubjectUtils
Utility methods used in
Subject implementors.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classMissing or unexpected values from a collection assertion, with equal objects grouped together and, in some cases, type information added.private static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static <T> List<T> accumulate(T first, T second, T... rest) addTypeInfoToEveryItem(Iterable<?> items) (package private) static <T> Iterable<T> annotateEmptyStrings(Iterable<T> items) Returns an iterable with all empty strings replaced by a non-empty human understandable indicator for an empty string.(package private) static <E> com.google.common.collect.ImmutableList<E> append(com.google.common.collect.ImmutableList<? extends E> list, E object) (package private) static <E> com.google.common.collect.ImmutableList<E> append(E[] array, E object) (package private) static <E> com.google.common.collect.ImmutableList<E> (package private) static StringcountDuplicates(Iterable<?> items) (package private) static StringcountDuplicatesAndAddTypeInfo(Iterable<?> itemsIterable) Makes a String representation ofitemswith collapsed duplicates and additional class info.(package private) static SubjectUtils.DuplicateGroupedAndTypedcountDuplicatesAndMaybeAddTypeInfoReturnObject(Iterable<?> itemsIterable, boolean addTypeInfo) Similar tocountDuplicatesAndAddTypeInfo(java.lang.Iterable<?>)andcountDuplicates(java.lang.Iterable<?>)but (a) only adds type info if requested and (b) returns a richer object containing the data.private static <T> SubjectUtils.NonHashingMultiset<T> countDuplicatesToMultiset(Iterable<T> items) (package private) static <T> int(package private) static StringentryString(com.google.common.collect.Multiset.Entry<?> entry) private static com.google.common.base.Optional<String> getHomogeneousTypeName(Iterable<?> items) Returns the name of the single type of all given items orOptional.absent()if no such type exists.(package private) static booleanhasMatchingToStringPair(Iterable<?> items1, Iterable<?> items2) Returns true if there is a pair of an item fromitems1and one initems2that has the sametoString()value without being equal.(package private) static <T> Collection<T> iterableToCollection(Iterable<T> iterable) (package private) static <T> List<T> iterableToList(Iterable<T> iterable) (package private) static StringiterableToStringWithTypeInfo(Iterable<?> itemsIterable) Makes a String representation ofitemswith additional class info.(package private) static StringobjectToTypeName(Object item) retainMatchingToString(Iterable<?> items, Iterable<?> itemsToCheck) Returns a new collection containing all elements initemsfor which there exists at least one element initemsToCheckthat has the sametoString()value without being equal.(package private) static <E> com.google.common.collect.ImmutableList<E> sandwich(E first, E[] array, E last)
-
Field Details
-
HUMAN_UNDERSTANDABLE_EMPTY_STRING
- See Also:
-
-
Constructor Details
-
SubjectUtils
private SubjectUtils()
-
-
Method Details
-
accumulate
-
countOf
-
countDuplicates
-
entryString
-
countDuplicatesToMultiset
-
countDuplicatesAndAddTypeInfo
Makes a String representation ofitemswith collapsed duplicates and additional class info.Example:
countDuplicatesAndAddTypeInfo([1, 2, 2, 3]) == "[1, 2 [3 copies]] (java.lang.Integer)"andcountDuplicatesAndAddTypeInfo([1, 2L]) == "[1 (java.lang.Integer), 2 (java.lang.Long)]". -
countDuplicatesAndMaybeAddTypeInfoReturnObject
static SubjectUtils.DuplicateGroupedAndTyped countDuplicatesAndMaybeAddTypeInfoReturnObject(Iterable<?> itemsIterable, boolean addTypeInfo) Similar tocountDuplicatesAndAddTypeInfo(java.lang.Iterable<?>)andcountDuplicates(java.lang.Iterable<?>)but (a) only adds type info if requested and (b) returns a richer object containing the data. -
iterableToStringWithTypeInfo
Makes a String representation ofitemswith additional class info.Example:
iterableToStringWithTypeInfo([1, 2]) == "[1, 2] (java.lang.Integer)"anditerableToStringWithTypeInfo([1, 2L]) == "[1 (java.lang.Integer), 2 (java.lang.Long)]". -
retainMatchingToString
Returns a new collection containing all elements initemsfor which there exists at least one element initemsToCheckthat has the sametoString()value without being equal.Example:
retainMatchingToString([1L, 2L, 2L], [2, 3]) == [2L, 2L] -
hasMatchingToStringPair
Returns true if there is a pair of an item fromitems1and one initems2that has the sametoString()value without being equal.Example:
hasMatchingToStringPair([1L, 2L], [1]) == true -
objectToTypeName
-
getHomogeneousTypeName
Returns the name of the single type of all given items orOptional.absent()if no such type exists. -
addTypeInfoToEveryItem
-
iterableToCollection
-
iterableToList
-
annotateEmptyStrings
Returns an iterable with all empty strings replaced by a non-empty human understandable indicator for an empty string.Returns the given iterable if it contains no empty strings.
-
concat
@SafeVarargs static <E> com.google.common.collect.ImmutableList<E> concat(Iterable<? extends E>... inputs) -
append
static <E> com.google.common.collect.ImmutableList<E> append(E[] array, E object) -
append
static <E> com.google.common.collect.ImmutableList<E> append(com.google.common.collect.ImmutableList<? extends E> list, E object) -
sandwich
static <E> com.google.common.collect.ImmutableList<E> sandwich(E first, E[] array, E last)
-