/** * Delegate call to {@link org.assertj.core.api.Assertions#filter(E[])} */ default <E> Filters<E> filter(E[] array) { return DELEGATE.filter(array); }
/** * Delegate call to {@link org.assertj.core.api.Assertions#filter(Iterable)} */ default <E> Filters<E> filter(Iterable<E> iterableToFilter) { return DELEGATE.filter(iterableToFilter); }
@Test public void should_create_filter_from_iterable() { Filters<Player> filter = filter(players); assertThat(filter.get()).isEqualTo(players); }
@Test public void should_create_filter_from_array() { Player[] playersArray = players.toArray(new Player[0]); Filters<Player> filter = filter(playersArray); assertThat(filter.get()).isEqualTo(players); }
/** * Filter the iterable under test keeping only elements having a property or field equal to {@code expectedValue}, the * property/field is specified by {@code propertyOrFieldName} parameter. * <p> * The filter first tries to get the value from a property (named {@code propertyOrFieldName}), if no such property * exists it tries to read the value from a field. Reading private fields is supported by default, this can be * globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean) * Assertions.setAllowExtractingPrivateFields(false)}. * <p> * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is * considered to be null, thus reading "address.street.name" value will return null if "street" value is null. * <p> * * As an example, let's check all employees 800 years old (yes, special employees): * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * Employee noname = new Employee(4L, null, 50); * * List<Employee> employees = newArrayList(yoda, luke, obiwan, noname); * * assertThat(employees).filteredOn("age", 800) * .containsOnly(yoda, obiwan);</code></pre> * * Nested properties/fields are supported: * <pre><code class='java'> // Name is bean class with 'first' and 'last' String properties * * // name is null for noname => it does not match the filter on "name.first" * assertThat(employees).filteredOn("name.first", "Luke") * .containsOnly(luke); * * assertThat(employees).filteredOn("name.last", "Vader") * .isEmpty();</code></pre> * <p> * If you want to filter on null value, use {@link #filteredOnNull(String)} as Java will resolve the call to * {@link #filteredOn(String, FilterOperator)} instead of this method. * <p> * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the iterable * elements. * <p> * You can chain filters: * <pre><code class='java'> // fellowshipOfTheRing is a list of TolkienCharacter having race and name fields * // 'not' filter is statically imported from Assertions.not * * assertThat(fellowshipOfTheRing).filteredOn("race.name", "Man") * .filteredOn("name", not("Boromir")) * .containsOnly(aragorn);</code></pre> * * If you need more complex filter, use {@link #filteredOn(Predicate)} or {@link #filteredOn(Condition)}. * * @param propertyOrFieldName the name of the property or field to read * @param expectedValue the value to compare element's property or field with * @return a new assertion object with the filtered iterable under test * @throws IllegalArgumentException if the given propertyOrFieldName is {@code null} or empty. * @throws IntrospectionError if the given propertyOrFieldName can't be found in one of the iterable elements. */ @CheckReturnValue public AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> filteredOn(String propertyOrFieldName, Object expectedValue) { Filters<? extends ELEMENT> filter = filter((Iterable<? extends ELEMENT>) actual); Iterable<? extends ELEMENT> filteredIterable = filter.with(propertyOrFieldName, expectedValue).get(); return newListAssertInstance(newArrayList(filteredIterable)); }
/** * Filter the iterable under test keeping only elements whose property or field specified by * {@code propertyOrFieldName} is null. * <p> * The filter first tries to get the value from a property (named {@code propertyOrFieldName}), if no such property * exists it tries to read the value from a field. Reading private fields is supported by default, this can be * globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean) * Assertions.setAllowExtractingPrivateFields(false)}. * <p> * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is * considered to be null, thus reading "address.street.name" value will return null if "street" value is null. * <p> * As an example, let's check all employees 800 years old (yes, special employees): * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * Employee noname = new Employee(4L, null, 50); * * List<Employee> employees = newArrayList(yoda, luke, obiwan, noname); * * assertThat(employees).filteredOnNull("name") * .containsOnly(noname);</code></pre> * * Nested properties/fields are supported: * <pre><code class='java'> // Name is bean class with 'first' and 'last' String properties * * assertThat(employees).filteredOnNull("name.last") * .containsOnly(yoda, obiwan, noname);</code></pre> * * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the iterable * elements. * <p> * If you need more complex filter, use {@link #filteredOn(Predicate)} or {@link #filteredOn(Condition)}. * * @param propertyOrFieldName the name of the property or field to read * @return a new assertion object with the filtered iterable under test * @throws IntrospectionError if the given propertyOrFieldName can't be found in one of the iterable elements. */ @CheckReturnValue public AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> filteredOnNull(String propertyOrFieldName) { // can't call filteredOn(String propertyOrFieldName, null) as it does not work with soft assertions proxying // mechanism, it would lead to double proxying which is not handle properly (improvements needed in our proxy mechanism) Filters<? extends ELEMENT> filter = filter((Iterable<? extends ELEMENT>) actual); Iterable<? extends ELEMENT> filteredIterable = filter.with(propertyOrFieldName, null).get(); return newListAssertInstance(newArrayList(filteredIterable)); }
/** * Filter the iterable under test keeping only elements having a property or field matching the filter expressed with * the {@link FilterOperator}, the property/field is specified by {@code propertyOrFieldName} parameter. * <p> * The existing filters are : * <ul> * <li> {@link Assertions#not(Object) not(Object)}</li> * <li> {@link Assertions#in(Object...) in(Object...)}</li> * <li> {@link Assertions#notIn(Object...) notIn(Object...)}</li> * </ul> * <p> * Whatever filter is applied, it first tries to get the value from a property (named {@code propertyOrFieldName}), if * no such property exists it tries to read the value from a field. Reading private fields is supported by default, * this can be globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean) * Assertions.setAllowExtractingPrivateFields(false)}. * <p> * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is * considered to be null, thus reading "address.street.name" value will return null if "street" value is null. * <p> * * As an example, let's check stuff on some special employees : * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * * List<Employee> employees = newArrayList(yoda, luke, obiwan, noname); * * // 'not' filter is statically imported from Assertions.not * assertThat(employees).filteredOn("age", not(800)) * .containsOnly(luke); * * // 'in' filter is statically imported from Assertions.in * // Name is bean class with 'first' and 'last' String properties * assertThat(employees).filteredOn("name.first", in("Yoda", "Luke")) * .containsOnly(yoda, luke); * * // 'notIn' filter is statically imported from Assertions.notIn * assertThat(employees).filteredOn("name.first", notIn("Yoda", "Luke")) * .containsOnly(obiwan);</code></pre> * * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the iterable * elements. * <p> * Note that combining filter operators is not supported, thus the following code is not correct: * <pre><code class='java'> // Combining filter operators like not(in(800)) is NOT supported * // -> throws UnsupportedOperationException * assertThat(employees).filteredOn("age", not(in(800))) * .contains(luke);</code></pre> * <p> * You can chain filters: * <pre><code class='java'> // fellowshipOfTheRing is a list of TolkienCharacter having race and name fields * // 'not' filter is statically imported from Assertions.not * * assertThat(fellowshipOfTheRing).filteredOn("race.name", "Man") * .filteredOn("name", not("Boromir")) * .containsOnly(aragorn);</code></pre> * * If you need more complex filter, use {@link #filteredOn(Predicate)} or {@link #filteredOn(Condition)}. * * @param propertyOrFieldName the name of the property or field to read * @param filterOperator the filter operator to apply * @return a new assertion object with the filtered iterable under test * @throws IllegalArgumentException if the given propertyOrFieldName is {@code null} or empty. */ @CheckReturnValue public AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> filteredOn(String propertyOrFieldName, FilterOperator<?> filterOperator) { checkNotNull(filterOperator); Filters<? extends ELEMENT> filter = filter((Iterable<? extends ELEMENT>) actual).with(propertyOrFieldName); filterOperator.applyOn(filter); return newListAssertInstance(newArrayList(filter.get())); }
/** * Filter the iterable under test keeping only elements matching the given {@link Condition}. * <p> * If you prefer {@link Predicate} over {@link Condition}, use {@link #filteredOn(Predicate)}. * <p> * Example : check old employees whose age > 100: * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * Employee noname = new Employee(4L, null, 50); * * List<Employee> employees = newArrayList(yoda, luke, obiwan, noname); * * // old employee condition, "old employees" describes the condition in error message * // you just have to implement 'matches' method * Condition<Employee> oldEmployees = new Condition<Employee>("old employees") { * {@literal @}Override * public boolean matches(Employee employee) { * return employee.getAge() > 100; * } * }; * } * assertThat(employees).filteredOn(oldEmployees) * .containsOnly(yoda, obiwan);</code></pre> * * You can combine {@link Condition} with condition operator like {@link Not}: * <pre><code class='java'> // 'not' filter is statically imported from Assertions.not * assertThat(employees).filteredOn(not(oldEmployees)) * .contains(luke, noname);</code></pre> * * @param condition the filter condition / predicate * @return a new assertion object with the filtered iterable under test * @throws IllegalArgumentException if the given condition is {@code null}. */ @CheckReturnValue public AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> filteredOn(Condition<? super ELEMENT> condition) { Filters<? extends ELEMENT> filter = filter((Iterable<? extends ELEMENT>) actual); Iterable<? extends ELEMENT> filteredIterable = filter.being(condition).get(); return newListAssertInstance(newArrayList(filteredIterable)); }
/** * Filter the array under test into a list composed of elements having a property or field matching the filter expressed with * the {@link FilterOperator}, the property/field is specified by {@code propertyOrFieldName} parameter. * <p> * The existing filters are : * <ul> * <li> {@link Assertions#not(Object) not(Object)}</li> * <li> {@link Assertions#in(Object...) in(Object...)}</li> * <li> {@link Assertions#notIn(Object...) notIn(Object...)}</li> * </ul> * <p> * Whatever filter is applied, it first tries to get the value from a property (named {@code propertyOrFieldName}), if * no such property exists it tries to read the value from a field. Reading private fields is supported by default, * this can be globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean) * Assertions.setAllowExtractingPrivateFields(false)}. * <p> * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is * considered to be null, thus reading "address.street.name" value will return null if "street" value is null. * <p> * As an example, let's check stuff on some special employees : * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * * Employee[] employees = new Employee[] { yoda, luke, obiwan, noname }; * * // 'not' filter is statically imported from Assertions.not * assertThat(employees).filteredOn("age", not(800)) * .containsOnly(luke); * * // 'in' filter is statically imported from Assertions.in * // Name is bean class with 'first' and 'last' String properties * assertThat(employees).filteredOn("name.first", in("Yoda", "Luke")) * .containsOnly(yoda, luke); * * // 'notIn' filter is statically imported from Assertions.notIn * assertThat(employees).filteredOn("name.first", notIn("Yoda", "Luke")) * .containsOnly(obiwan);</code></pre> * * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the array * elements. * <p> * Note that combining filter operators is not supported, thus the following code is not correct: * <pre><code class='java'> // Combining filter operators like not(in(800)) is NOT supported * // -> throws UnsupportedOperationException * assertThat(employees).filteredOn("age", not(in(800))) * .contains(luke);</code></pre> * <p> * You can chain filters: * <pre><code class='java'> // fellowshipOfTheRing is an array of TolkienCharacter having race and name fields * // 'not' filter is statically imported from Assertions.not * * assertThat(fellowshipOfTheRing).filteredOn("race.name", "Man") * .filteredOn("name", not("Boromir")) * .containsOnly(aragorn);</code></pre> * <p> * If you need more complex filter, use {@link #filteredOn(Condition)} or {@link #filteredOn(Predicate)} and * provide a {@link Condition} or {@link Predicate} to specify the filter to apply. * * @param propertyOrFieldName the name of the property or field to read * @param filterOperator the filter operator to apply * @return a new assertion object with the filtered list under test * @throws IllegalArgumentException if the given propertyOrFieldName is {@code null} or empty. */ @CheckReturnValue public AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> filteredOn(String propertyOrFieldName, FilterOperator<?> filterOperator) { checkNotNull(filterOperator); Filters<? extends ELEMENT> filter = filter(actual).with(propertyOrFieldName); filterOperator.applyOn(filter); return newListAssertInstance(newArrayList(filter.get())); }
/** * Filter the array under test keeping only elements having a property or field matching the filter expressed with * the {@link FilterOperator}, the property/field is specified by {@code propertyOrFieldName} parameter. * <p> * The existing filters are : * <ul> * <li> {@link Assertions#not(Object) not(Object)}</li> * <li> {@link Assertions#in(Object...) in(Object...)}</li> * <li> {@link Assertions#notIn(Object...) notIn(Object...)}</li> * </ul> * <p> * Whatever filter is applied, it first tries to get the value from a property (named {@code propertyOrFieldName}), if * no such property exists it tries to read the value from a field. Reading private fields is supported by default, * this can be globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean) * Assertions.setAllowExtractingPrivateFields(false)}. * <p> * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is * considered to be null, thus reading "address.street.name" value will return null if "street" value is null. * <p> * * As an example, let's check stuff on some special employees : * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800); * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800); * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26); * * AtomicReferenceArray<Employee> employees = new AtomicReferenceArray<>(new Employee[]{ yoda, luke, obiwan, noname }); * * // 'not' filter is statically imported from Assertions.not * assertThat(employees).filteredOn("age", not(800)) * .containsOnly(luke); * * // 'in' filter is statically imported from Assertions.in * // Name is bean class with 'first' and 'last' String properties * assertThat(employees).filteredOn("name.first", in("Yoda", "Luke")) * .containsOnly(yoda, luke); * * // 'notIn' filter is statically imported from Assertions.notIn * assertThat(employees).filteredOn("name.first", notIn("Yoda", "Luke")) * .containsOnly(obiwan);</code></pre> * * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the array * elements. * <p> * Note that combining filter operators is not supported, thus the following code is not correct: * <pre><code class='java'> // Combining filter operators like not(in(800)) is NOT supported * // -> throws UnsupportedOperationException * assertThat(employees).filteredOn("age", not(in(800))) * .contains(luke);</code></pre> * <p> * You can chain filters: * <pre><code class='java'> // fellowshipOfTheRing is an array of TolkienCharacter having race and name fields * // 'not' filter is statically imported from Assertions.not * * assertThat(fellowshipOfTheRing).filteredOn("race.name", "Man") * .filteredOn("name", not("Boromir")) * .containsOnly(aragorn);</code></pre> * * If you need more complex filter, use {@link #filteredOn(Condition)} and provide a {@link Condition} to specify the * filter to apply. * * @param propertyOrFieldName the name of the property or field to read * @param filterOperator the filter operator to apply * @return a new assertion object with the filtered array under test * @throws IllegalArgumentException if the given propertyOrFieldName is {@code null} or empty. * @since 2.7.0 / 3.7.0 */ @CheckReturnValue public AtomicReferenceArrayAssert<T> filteredOn(String propertyOrFieldName, FilterOperator<?> filterOperator) { checkNotNull(filterOperator); Filters<? extends T> filter = filter(array).with(propertyOrFieldName); filterOperator.applyOn(filter); return new AtomicReferenceArrayAssert<>(new AtomicReferenceArray<>(toArray(filter.get()))); }
/** * Delegate call to public static <E> org.assertj.core.api.filter.Filters<E> org.assertj.core.api.Assertions.filter(E[]) * {@link org.assertj.core.api.Assertions#filter(java.lang.Object[])} */ default <E> Filters<E> filter(E[] array) { return Assertions.filter(array); }
/** * Delegate call to public static <E> org.assertj.core.api.filter.Filters<E> org.assertj.core.api.Assertions.filter(java.lang.Iterable<E>) * {@link org.assertj.core.api.Assertions#filter(java.lang.Iterable)} */ default <E> Filters<E> filter(Iterable<E> iterableToFilter) { return Assertions.filter(iterableToFilter); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. * <p> * Typical usage with {@link Condition} : * * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20).and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the array elements type. * @param array the array to filter. * @return the created <code>{@link Filters}</code>. */ default <E> Filters<E> filter(final E[] array) { return Assertions.filter(array); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given {@link Iterable} is not modified, the filters are performed on a copy. * <p> * Typical usage with {@link Condition} : * * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20) * .and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the {@link Iterable} elements type. * @param iterableToFilter the {@code Iterable} to filter. * @return the created <code>{@link Filters}</code>. */ default <E> Filters<E> filter(final Iterable<E> iterableToFilter) { return Assertions.filter(iterableToFilter); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. * <p> * Typical usage with {@link Condition} : * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20).and("assistsPerGame") * .greaterThan(7).get()).containsOnly(james, rose);</code></pre> * * @param <E> the array elements type. * @param array the array to filter. * @throws NullPointerException if the given array is {@code null}. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(E[] array) { return Filters.filter(array); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given {@link Iterable} is not modified, the filters are performed on a copy. * <p> * Typical usage with {@link Condition} : * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20) * .and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the iterable elements type. * @param iterableToFilter the {@code Iterable} to filter. * @throws NullPointerException if the given iterable is {@code null}. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(Iterable<E> iterableToFilter) { return Filters.filter(iterableToFilter); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. * <p> * Typical usage with {@link Condition} : * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20).and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the array elements type. * @param array the array to filter. * @throws NullPointerException if the given array is {@code null}. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(E[] array) { return Filters.filter(array); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given {@link Iterable} is not modified, the filters are performed on a copy. * <p> * Typical usage with {@link Condition} : * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20) * .and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the iterable elements type. * @param iterableToFilter the iterable to filter. * @throws NullPointerException if the given array is {@code null}. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(Iterable<E> iterableToFilter) { return Filters.filter(iterableToFilter); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. * <p> * Typical usage with {@link Condition} : * * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20).and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the array elements type. * @param array the array to filter. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(E[] array) { return Filters.filter(array); }
/** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all * AssertJ features (but you can use {@link Filters} if you prefer). * <p> * Note that the given {@link Iterable} is not modified, the filters are performed on a copy. * <p> * Typical usage with {@link Condition} : * * <pre><code class='java'> assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);</code></pre> * <p> * and with filter language based on java bean property : * * <pre><code class='java'> assertThat(filter(players).with("pointsPerGame").greaterThan(20) * .and("assistsPerGame").greaterThan(7).get()) * .containsOnly(james, rose);</code></pre> * * @param <E> the {@link Iterable} elements type. * @param iterableToFilter the {@code Iterable} to filter. * @return the created <code>{@link Filters}</code>. */ public static <E> Filters<E> filter(Iterable<E> iterableToFilter) { return Filters.filter(iterableToFilter); }