@GwtCompatible(emulated=true) public class Helpers extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static interface |
Helpers.GwtTransient
Private replacement for
com.google.gwt.user.client.rpc.GwtTransient to work around
build-system quirks. |
static class |
Helpers.NullsBefore
Compares strings in natural order except that null comes immediately before a given value.
|
static class |
Helpers.NullsBeforeB |
static class |
Helpers.NullsBeforeTwo |
Modifier and Type | Field and Description |
---|---|
private static java.util.Comparator<java.lang.Comparable> |
NATURAL_ORDER |
Constructor and Description |
---|
Helpers() |
Modifier and Type | Method and Description |
---|---|
static <E> boolean |
addAll(java.util.Collection<E> addTo,
java.lang.Iterable<? extends E> elementsToAdd) |
static void |
assertContains(java.lang.Iterable<?> actual,
java.lang.Object expected) |
static void |
assertContainsAllOf(java.lang.Iterable<?> actual,
java.lang.Object... expected) |
static void |
assertContentsAnyOrder(java.lang.Iterable<?> actual,
java.lang.Object... expected) |
static void |
assertContentsInOrder(java.lang.Iterable<?> actual,
java.lang.Object... expected) |
static void |
assertEmpty(java.lang.Iterable<?> iterable) |
static void |
assertEmpty(java.util.Map<?,?> map) |
static void |
assertEqualIgnoringOrder(java.lang.Iterable<?> expected,
java.lang.Iterable<?> actual) |
static void |
assertEqualInOrder(java.lang.Iterable<?> expected,
java.lang.Iterable<?> actual) |
(package private) static <E> java.util.List<E> |
castOrCopyToList(java.lang.Iterable<E> iterable) |
static <E> java.util.List<E> |
copyToList(E[] elements) |
static <E> java.util.List<E> |
copyToList(java.lang.Iterable<? extends E> elements) |
static <E> java.util.Set<E> |
copyToSet(E[] elements) |
static <E> java.util.Set<E> |
copyToSet(java.lang.Iterable<? extends E> elements) |
(package private) static <T> java.util.Iterator<T> |
cycle(java.lang.Iterable<T> iterable) |
static <K,V> java.util.Comparator<java.util.Map.Entry<K,V>> |
entryComparator(java.util.Comparator<? super K> keyComparator) |
(package private) static boolean |
equal(java.lang.Object a,
java.lang.Object b) |
(package private) static void |
fail(java.lang.Throwable cause,
java.lang.Object message) |
(package private) static <T> T |
get(java.util.Iterator<T> iterator,
int position) |
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> clazz,
java.lang.String name) |
private static boolean |
isEmpty(java.lang.Iterable<?> iterable) |
static <K,V> java.util.Map.Entry<K,V> |
mapEntry(K key,
V value) |
static <T> java.util.Collection<T> |
misleadingSizeCollection(int delta)
Returns a collection that simulates concurrent modification by
having its size method return incorrect values.
|
static <K,V> java.util.Map.Entry<K,V> |
nefariousMapEntry(K key,
V value)
Returns a "nefarious" map entry with the specified key and value,
meaning an entry that is suitable for testing that map entries cannot be
modified via a nefarious implementation of equals.
|
static <K extends java.lang.Comparable,V> |
orderEntriesByKey(java.util.List<java.util.Map.Entry<K,V>> insertionOrder) |
(package private) static <T> java.lang.Iterable<T> |
reverse(java.util.List<T> list) |
static <T> void |
testComparator(java.util.Comparator<? super T> comparator,
java.util.List<T> valuesInExpectedOrder)
Asserts that all pairs of
T values within valuesInExpectedOrder are ordered
consistently between their order within valuesInExpectedOrder and the order implied by
the given comparator . |
static <T> void |
testComparator(java.util.Comparator<? super T> comparator,
T... valuesInExpectedOrder)
Asserts that all pairs of
T values within valuesInExpectedOrder are ordered
consistently between their order within valuesInExpectedOrder and the order implied by
the given comparator . |
static <T extends java.lang.Comparable<? super T>> |
testCompareToAndEquals(java.util.List<T> valuesInExpectedOrder) |
private static final java.util.Comparator<java.lang.Comparable> NATURAL_ORDER
static boolean equal(java.lang.Object a, java.lang.Object b)
public static <E> java.util.List<E> copyToList(java.lang.Iterable<? extends E> elements)
public static <E> java.util.List<E> copyToList(E[] elements)
public static <E> java.util.Set<E> copyToSet(java.lang.Iterable<? extends E> elements)
public static <E> java.util.Set<E> copyToSet(E[] elements)
public static <K,V> java.util.Map.Entry<K,V> mapEntry(K key, V value)
private static boolean isEmpty(java.lang.Iterable<?> iterable)
public static void assertEmpty(java.lang.Iterable<?> iterable)
public static void assertEmpty(java.util.Map<?,?> map)
public static void assertEqualInOrder(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual)
public static void assertContentsInOrder(java.lang.Iterable<?> actual, java.lang.Object... expected)
public static void assertEqualIgnoringOrder(java.lang.Iterable<?> expected, java.lang.Iterable<?> actual)
public static void assertContentsAnyOrder(java.lang.Iterable<?> actual, java.lang.Object... expected)
public static void assertContains(java.lang.Iterable<?> actual, java.lang.Object expected)
public static void assertContainsAllOf(java.lang.Iterable<?> actual, java.lang.Object... expected)
public static <E> boolean addAll(java.util.Collection<E> addTo, java.lang.Iterable<? extends E> elementsToAdd)
static <T> java.lang.Iterable<T> reverse(java.util.List<T> list)
static <T> java.util.Iterator<T> cycle(java.lang.Iterable<T> iterable)
static <T> T get(java.util.Iterator<T> iterator, int position)
static void fail(java.lang.Throwable cause, java.lang.Object message)
public static <K,V> java.util.Comparator<java.util.Map.Entry<K,V>> entryComparator(java.util.Comparator<? super K> keyComparator)
public static <T> void testComparator(java.util.Comparator<? super T> comparator, T... valuesInExpectedOrder)
T
values within valuesInExpectedOrder
are ordered
consistently between their order within valuesInExpectedOrder
and the order implied by
the given comparator
.testComparator(Comparator, List)
public static <T> void testComparator(java.util.Comparator<? super T> comparator, java.util.List<T> valuesInExpectedOrder)
T
values within valuesInExpectedOrder
are ordered
consistently between their order within valuesInExpectedOrder
and the order implied by
the given comparator
.
In detail, this method asserts
comparator.compare(t, t) = 0
for all t
in
valuesInExpectedOrder
; and
comparator.compare(ti, tj) < 0
and
comparator.compare(tj, ti) > 0
for i < j
, where
ti = valuesInExpectedOrder.get(i)
and tj = valuesInExpectedOrder.get(j)
.public static <T extends java.lang.Comparable<? super T>> void testCompareToAndEquals(java.util.List<T> valuesInExpectedOrder)
public static <T> java.util.Collection<T> misleadingSizeCollection(int delta)
delta
- the difference between the true size of the
collection and the values returned by the size methodpublic static <K,V> java.util.Map.Entry<K,V> nefariousMapEntry(K key, V value)
static <E> java.util.List<E> castOrCopyToList(java.lang.Iterable<E> iterable)
public static <K extends java.lang.Comparable,V> java.lang.Iterable<java.util.Map.Entry<K,V>> orderEntriesByKey(java.util.List<java.util.Map.Entry<K,V>> insertionOrder)
@GwtIncompatible public static java.lang.reflect.Method getMethod(java.lang.Class<?> clazz, java.lang.String name)