/gallego

Lightweight Optionals for Java 7

Primary LanguageJavaApache License 2.0Apache-2.0

Gallego

Optionals for Java 7

It depends...

Someone in Galicia

Build Status Bintray

This a lightweight copy of Guava's Optional interface.

For more awesome information, check out Guava wiki on Using/avoiding null.

Basic usage

Optional<Integer> possible = Optional.of(5);
possible.isPresent(); // returns true
possible.get(); // returns 5

More info in Guava's wiki

Why?

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.

Download

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>