All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fitnesse.wikitext.parser.Maybe Maven / Gradle / Ivy

There is a newer version: 20250223
Show newest version
package fitnesse.wikitext.parser;

public class Maybe {
    public static final Maybe noString = new Maybe<>("*nothing*", "");
    public static final Maybe noDouble = new Maybe<>(0.0, "");
    public static final Maybe noInteger = new Maybe<>(0, "");
    public static final Maybe noCharacter = new Maybe<>('\0', "");

    private final T value;
    private final String nothingReason;

    public Maybe(T value) { this(value, null); }

    public Maybe() { this(null, ""); }

    public static  Maybe nothingBecause(String nothingReason) {
        return new Maybe<>(null, nothingReason);
    }

    private Maybe(T value, String nothingReason) {
        this.value = value;
        this.nothingReason = nothingReason;
    }

    public T getValue() { return value; }
    public boolean isNothing() { return nothingReason != null; }
    public String because() { return nothingReason; }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy