@@ -0,0 +1,2458 @@
+/*%0A * Copyright (c) 2013 - 2014 xxyy (Philipp Nowak; devnull@nowak-at.net). All rights reserved.%0A *%0A * Any usage, including, but not limited to, compiling, running, redistributing, printing,%0A *  copying and reverse-engineering is strictly prohibited without explicit written permission%0A *  from the original author and may result in legal steps being taken.%0A */%0A%0Apackage io.github.xxyy.common.misc;%0A%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * An %7B@link java.util.Optional%7D which can contain NULL values.%0A *%0A * @author %3Ca href=%22http://xxyy.github.io/%22%3Exxyy%3C/a%3E%0A * @since 19.8.14%0A */%0Apublic class NullableOptional%3CT%3E %7B%0A    private final T value;%0A    private final boolean present;%0A%0A    private NullableOptional(T value, boolean present) %7B%0A        this.value = value;%0A        this.present = present;%0A    %7D%0A%0A    /**%0A     * Gets the value, if present.%0A     *%0A     * @return the value%0A     * @throws java.util.NoSuchElementException if no value is present%0A     */%0A    public T get() %7B%0A        if (!isPresent()) %7B%0A            throw new NoSuchElementException(%22No value present%22);%0A        %7D%0A%0A        return value;%0A    %7D%0A%0A    /**%0A     * Gets the value if present or returns a provided default otherwise.%0A     *%0A     * @param def the default to return if no value is present%0A     * @return the value or the default if no value is present%0A     */%0A    public T orElse(T def) %7B%0A        if (isPresent()) %7B%0A            return value;%0A        %7D else %7B%0A            return def;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Gets the value if present or NULL otherwise.%0A     *%0A     * @return the value or NULL if no value is present%0A     */%0A    public T orNull() %7B%0A        return orElse(null);%0A    %7D%0A%0A    /**%0A     * @return whethher a value is present in the NullableOptional%0A     */%0A    public boolean isPresent() %7B%0A        return present;%0A    %7D%0A%0A    /**%0A     * Creates a new NullableOptional.%0A     *%0A     * @param value the value the NullableOptional will contain%0A     * @param %3CT%3E   the type of the value%0A     * @return a NullableOptional containing specified value%0A     */%0A    public static %3CT%3E NullableOptional%3CT%3E of(T value) %7B%0A        return new NullableOptional%3C%3E(value, true);%0A    %7D%0A%0A    /**%0A     * Creates a new, empty NullableOptional.%0A     *%0A     * @param %3CT%3E the type of the value the NullableOptional does not have%0A     * @return an empty NullableOptional%0A     */%0A    public static %3CT%3E NullableOptional%3CT%3E of() %7B%0A        return new NullableOptional%3C%3E(null, false);%0A    %7D%0A%7D%0A

Add NullableOptional