@@ -0,0 +1,2155 @@
+package com.novoda.downloadmanager;%0A%0Apublic final class Optional%3CT%3E %7B%0A%0A    @SuppressWarnings(%22unchecked%22)  // Type erasure has us covered here, we don't care%0A    private static final Optional ABSENT = new Optional(null);%0A%0A    private final T data;%0A%0A    @SuppressWarnings(%22unchecked%22)  // Type erasure has us covered here, we don't care%0A    public static %3CT%3E Optional%3CT%3E absent() %7B%0A        return ABSENT;%0A    %7D%0A%0A    public static %3CT%3E Optional%3CT%3E fromNullable(T data) %7B%0A        if (data == null) %7B%0A            return absent();%0A        %7D%0A        return new Optional%3C%3E(data);%0A    %7D%0A%0A    public static %3CT%3E Optional%3CT%3E of(T data) %7B%0A        if (data == null) %7B%0A            throw new IllegalArgumentException(%22Data cannot be null. Use Optional.fromNullable(maybeNullData).%22);%0A        %7D%0A        return new Optional%3C%3E(data);%0A    %7D%0A%0A    private Optional(T data) %7B%0A        this.data = data;%0A    %7D%0A%0A    public boolean isPresent() %7B%0A        return data != null;%0A    %7D%0A%0A    public boolean isAbsent() %7B%0A        return !isPresent();%0A    %7D%0A%0A    public T get() %7B%0A        if (!isPresent()) %7B%0A            throw new IllegalStateException(%22You must check if data is present before using get()%22);%0A        %7D%0A        return data;%0A    %7D%0A%0A    public T or(T elseCase) %7B%0A        return isPresent() ? get() : elseCase;%0A    %7D%0A%0A    public Optional%3CT%3E or(Optional%3CT%3E elseCase) %7B%0A        return isPresent() ? this : elseCase;%0A    %7D%0A%0A    public Optional%3CT%3E or(Func0%3COptional%3CT%3E%3E elseFunc) %7B%0A        return isPresent() ? this : elseFunc.call();%0A    %7D%0A%0A    public interface Func0%3CV%3E %7B%0A%0A        V call();%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) %7B%0A            return true;%0A        %7D%0A        if (o == null %7C%7C getClass() != o.getClass()) %7B%0A            return false;%0A        %7D%0A%0A        Optional%3C?%3E optional = (Optional%3C?%3E) o;%0A%0A        return data != null ? data.equals(optional.data) : optional.data == null;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return data != null ? data.hashCode() : 0;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return String.format(%22Optional%3C%25s%3E%22, isAbsent() ? %22Absent%22 : data.toString());%0A    %7D%0A%7D%0A

Add Optional to the project.