Package org.cactoos.iterable
Class Filtered<X>
- java.lang.Object
-
- org.cactoos.iterable.IterableEnvelope<X>
-
- org.cactoos.iterable.Filtered<X>
-
- Type Parameters:
X
- Type of item
- All Implemented Interfaces:
Iterable<X>
public final class Filtered<X> extends IterableEnvelope<X>
Filtered iterable.You can use it in order to create a declarative/lazy version of a filtered collection/iterable. For example, this code will create a list of two strings "hello" and "world":
Iterable<String> list = new Filtered<>( new ArrayOf<>( "hey", "hello", "world" ), input -> input.length() > 4 );
There is no thread-safety guarantee.
- Since:
- 0.1
- See Also:
Filtered
-
-
Method Summary
-
Methods inherited from class org.cactoos.iterable.IterableEnvelope
equals, hashCode, iterator, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Filtered
@SafeVarargs public Filtered(Func<? super X,Boolean> fnc, X... src)
Ctor.- Parameters:
fnc
- Predicatesrc
- Source iterable- Since:
- 0.21
-
Filtered
public Filtered(Func<? super X,Boolean> fnc, Iterable<? extends X> src)
Ctor.- Parameters:
fnc
- Predicatesrc
- Source iterable
-
-