Optionals for Java 7
It depends...
— Someone in Galicia
This a lightweight copy of Guava's Optional interface.
For more awesome information, check out Guava wiki on Using/avoiding null.
Optional<Integer> possible = Optional.of(5);
possible.isPresent(); // returns true
possible.get(); // returns 5
More info in Guava's wiki
Java 8 Optionals are nice, but some of us can't enjoy them just yet*(Android)*.
Guava Optionals are great, but it's such a big dependency to have just for the Optional interface if you don't want to be messing around with Proguard and such.
This little library lets you use Optionals without adding more code than needed.
The library is available in JCenter.
Gradle:
compile 'com.sloydev:gallego:1.0.0'
Maven:
<dependency>
<groupId>com.sloydev</groupId>
<artifactId>gallego</artifactId>
<version>1.0.0</version>
</dependency>