Map, reduce and group-by on collections

// Map
 
List<String> items = New.list("a", "bbbbb", "cc");["a","bbbbb","cc"]
 
Do.map(items).to(s -> s.length());[1,5,2]
 
// Reduce
Do.reduce(items).by((a, b) -> a + ":" + b).orElse("");"a:bbbbb:cc"
 
Do.reduce(items).by("@", (a, b) -> a + ":" + b);"@:a:bbbbb:cc"
 
// Group-by
Do.group(items).by(s -> s.length());{"1":["a"],"2":["cc"],"5":["bbbbb"]}

Project setup with Maven

To run the example, you need to create a new Java 8 project and configure it properly using Maven:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.example</groupId>
    <artifactId>my-example</artifactId>
    <version>1.0.0-SNAPSHOT</version>
 
    <dependencies>
        <dependency>
            <groupId>org.rapidoid</groupId>
            <artifactId>rapidoid-fluent</artifactId>
            <version>5.5.0</version>
        </dependency>
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
</project>

Building the project with Maven is easy:
mvn package