compacted-collections brings the full power of object-oriented programming to your Java collections.
Modelled closely on the standard Ruby library.
Features:
Built on top of well known, high quality libraries:
listOf("1", "2", "3", "4", "4").map(toInt()).filter(greaterThan(1)).reverse();
listOf("1", "2").map(toInt());
listOf("1", "2").map(toInt()).reduce(sum());
listOf(1, 2, 3).filter(greaterThan(1));
listOf(1, 2, 3).reject(lessThan(3));
listOf(1, 2).find(equalTo(1));
listOf(1, 2).first();
listOf(1, 2, 3).first(2);
listOf(1, 2).last();
listOf(1, 2, 3).last(2);
listOf(1, 3, 2).sort(natural());
listOf(1, 2, 3).reverse();
listOf("1", "2", "3").join(", ");
listOf("1", "2", "2").unique();
listOf("1", "2", null).compact();
This project is built using Apache Maven.
You can easily add it to any maven enabled project like so:
...
<repositories>
<repository>
<id>compacted-collections</id>
<url>http://compactcode.github.com/compacted-collections/mavenrepo</url>
</repository>
</repositories>
...
<dependencies>
<dependency>
<groupId>com.compactcode</groupId>
<artifactId>compacted-collections</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
...
If you'd like to see some compacted collections in action, check out the example project.