enumerable4j is a Ruby's well known Enumerable
ported to java
.
Get the latest version here:
<dependency>
<groupId>io.github.dgroup</groupId>
<artifactId>enumerable4j</artifactId>
<version>${version}</version>
</dependency>
Java version required: 1.8+.
enumerable4j (MIT) | Java 8 | cactoos (MIT) | eclipse-collections (EDL) |
---|---|---|---|
.all(...) |
.stream().allMatch(...); |
new And<>(...,...).value() |
tbd |
.any(...) |
.stream().anyMatch(...); |
new Or<>(...,...).value() |
tbd |
.none(...) |
.stream().noneMatch(...); |
new And<>(...,...).value() |
tbd |
.select(...) |
.stream().filter(...).collect(Collectors.toList()) |
new Filtered<>(...,...) |
tbd |
.count(...) |
.stream().filter(...).count() |
- |
tbd |
Collection<Integer> src = new EnumerableOf<>(1, 2, 3);
boolean allPositive = src.all(v -> v > 0); // true
Collection<Integer> src = new EnumerableOf<>(-1, 0, 1);
boolean oneIsPositive = src.any(v -> v > 0); // true
Collection<Integer> src = new EnumerableOf<>(-2, -1, 0);
boolean noneIsPositive = src.none(v -> v > 0); // true
Collection<Integer> src = new EnumerableOf<>(-1, 1, 2);
Collection<Integer> positive = src.select(v -> v > 0); // [1, 2]
Collection<Integer> src = new EnumerableOf<>(0, 1, 2);
Collection<Integer> positive = src.map(v -> v + 1); // [1, 2, 3]
Collection<Integer> src = new EnumerableOf<>(-1, 0, 1, 2);
long countNegative = src.count(val -> val < 0); // 1
long count = src.count(null); // 4
- Pull requests are welcome! Don't forget to add your name to contribution section and run this,
beforehand:
mvn -Pqulice clean install
- Everyone interacting in this project’s codebases, issue trackers, chat rooms is expected to follow the code of conduct.
- Latest maven coordinates here:
<dependency> <groupId>io.github.dgroup</groupId> <artifactId>enumerable4j</artifactId> <version>${version}</version> </dependency>
- dgroup as Yurii Dubinka (yurii.dubinka@gmail.com)
- smithros as Rostyslav Koval (kovalr2000@gmail.com)
- ashutosh as Ashutosh Singh (s.ashutosh@hotmail.com)