private Filters(Iterable<E> iterable) { this.initialIterable = iterable; // copy list to avoid modifying iterable this.filteredIterable = newArrayList(iterable); }
private Filters(E[] array) { this(newArrayList(array)); }
@SafeVarargs public static <T> ArrayList<T> list(T... elements) { return newArrayList(elements); }
private List<DateFormat> dateFormatsInOrderOfUsage() { List<DateFormat> allDateFormatsInOrderOfUsage = newArrayList(userDateFormats.get()); allDateFormatsInOrderOfUsage.addAll(DEFAULT_DATE_FORMATS); return allDateFormatsInOrderOfUsage; }
@SafeVarargs public static <T> Iterable<T> iterable(T... elements) { if (elements == null) return null; ArrayList<T> list = newArrayList(); java.util.Collections.addAll(list, elements); return list; }
private static List<StackTraceElement> stackTraceInCurrentThread() { return newArrayList(Thread.currentThread().getStackTrace()); }
@Override public AtomicReferenceArrayAssert<T> noneSatisfy(Consumer<? super T> restrictions) { iterables.assertNoneSatisfy(info, newArrayList(array), restrictions); return myself; }
/** * {@inheritDoc} */ @Override public SELF anySatisfy(Consumer<? super ELEMENT> requirements) { iterables.assertAnySatisfy(info, newArrayList(actual), requirements); return myself; } /**
/** * {@inheritDoc} */ @Override public SELF noneSatisfy(Consumer<? super ELEMENT> restrictions) { iterables.assertNoneSatisfy(info, newArrayList(actual), restrictions); return myself; }
/** * Appends the stack trace of the current thread to the one in the given <code>{@link Throwable}</code>. * * @param t the given {@code Throwable}. * @param methodToStartFrom the name of the method used as the starting point of the current thread's stack trace. */ public static void appendStackTraceInCurrentThreadToThrowable(Throwable t, String methodToStartFrom) { List<StackTraceElement> stackTrace = newArrayList(t.getStackTrace()); stackTrace.addAll(stackTraceInCurrentThread(methodToStartFrom)); t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); }
/** * Get the values of any array (primitive or not) into a {@code List<Object>}. * * @param array array passed as an object to support both primitive and Object array * @return the values of the given Object as a {@code List<Object>}. * @throws IllegalArgumentException it the given Object is not an array. */ public static List<Object> asList(Object array) { return newArrayList(asObjectArray(array)); }
/** * {@inheritDoc} */ @Override public SELF allSatisfy(Consumer<? super ELEMENT> requirements) { iterables.assertAllSatisfy(info, newArrayList(actual), requirements); return myself; }
private List<ELEMENT> initList() { if (list == null) list = Lists.newArrayList(stream.iterator()); return list; }
@Override protected ProxyableListAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable) { return new ProxyableListAssert<>(newArrayList(iterable)); }
@Override protected ListAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable) { return new ListAssert<>(newArrayList(iterable)); }
public <T> void assertDoesNotContainAnyElementsOf(AssertionInfo info, Object[] actual, Iterable<? extends T> iterable) { checkIsNotNullAndNotEmpty(iterable); List<T> values = newArrayList(iterable); assertDoesNotContain(info, actual, values.toArray()); }
private List<ELEMENT> initList() { if (list == null) { list = Lists.newArrayList(stream.iterator()); stream.close(); } return list; }
/** * {@inheritDoc} */ @Override public SELF allMatch(Predicate<? super ELEMENT> predicate, String predicateDescription) { iterables.assertAllMatch(info, newArrayList(actual), predicate, new PredicateDescription(predicateDescription)); return myself; }
void assertcontainsAll(AssertionInfo info, Failures failures, Object array, Iterable<?> iterable) { if (iterable == null) throw iterableToLookForIsNull(); assertNotNull(info, array); Object[] values = newArrayList(iterable).toArray(); Set<Object> notFound = new LinkedHashSet<>(); for (Object value : values) { if (!arrayContains(array, value)) notFound.add(value); } if (!notFound.isEmpty()) throw failures.failure(info, shouldContain(array, values, notFound, comparisonStrategy)); }
@Test public void array_subsetof_evals() { // list is a superset List<String> list = Lists.newArrayList("a", "b", "c", "d", "e", "f", "g"); assertThat(filter(where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(true); // list is exactly the same set (but in a different order) list = Lists.newArrayList("e", "d", "b", "c", "a"); assertThat(filter(where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(true); // list is missing one element list = Lists.newArrayList("a", "b", "c", "d"); assertThat(filter(where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(false); }