Java-Utils v1.0.0
This library is a set of Java Utility containing many useful Helper Classes which are described below.
#Stream Util
This library contains the StreamUtil, that contains flatten methods to flatten any stream of optionals to the stream of the type contained in the optionals. These flatten methods also supports boxed and non-boxed types of streams.
#Optional Util
This library contains the OptionalUtil, that flattens any optional of optional of any type to an optional of the type. Optional of a non-boxed optional type can also be flattened.
#Optional with Throwable
A new OptionalWithThrowable is added so that any map/flatMap/filter/ifPresent operation will accept the corresponding 'Funtional Interface with Throwable' which are added in this Java Utlitity.
#Funtional Interfaces with Throwable
With regular Functional Interfaces, exceptions or errors are not able chain the exceptions thrown inside the method to the caller. This required to handle the exception within the method definition itself. To handle this requirement new kind of Funtional Interfaces namely PredicateWithThrowable, FuntionWithThrowable, ConsumerWithThrowable and BiFunctionWithThrowable are added. Some of these are also used with OptionalWithThrowable implementation.
#Tuples
Inspired by Scala Tuples, this Java Utility includes convinent Generic Tuples from Tuple2 to Tuple10 and a convinient helper factory called Tuples to create them.
#Mappable Optionals
This library contains Mappable counterparts of OptionalInt, OptionalLong and OptionalDouble. This Mappable versions allows us to avoid boxing of primitive data typed streams. This implementation is done because the current versions of OptionalInt, OptionalLong and OptionalDouble do not provide a map or flatMap method, which forces us to use the Boxed verison of Optional.
To install the latest version, add the below pom dependency entry:
<dependency>
<groupId>org.vishag</groupId>
<artifactId>java-utils</artifactId>
<version>1.0.0</version>
</dependency>
#Examples
Added an example project that demonstrates the use of this Library.
To install the examples, add the below pom dependency entry:
<dependency>
<groupId>org.vishag</groupId>
<artifactId>java-utils-examples</artifactId>
<version>1.0.0</version>
</dependency>
Also, please look into the Unit tests for all the use-cases and examples.