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

xsbti.Maybe Maven / Gradle / Ivy

There is a newer version: 0.13.15
Show newest version
/* sbt -- Simple Build Tool
 * Copyright 2008, 2009, 2010  Mark Harrah
 */
package xsbti;

/** Intended as a lightweight carrier for scala.Option. */
public abstract class Maybe
{
	// private pending Scala bug #3642
	protected Maybe() {}

	public static  Maybe just(final s v)
	{
		return new Maybe() {
			public boolean isDefined() { return true; }
			public s get() { return v; }
		};
	}
	public static  Maybe nothing()
	{
		return new Maybe() {
			public boolean isDefined() { return false; }
			public s get() { throw new UnsupportedOperationException("nothing.get"); }
		};
	}

	public final boolean isEmpty() { return !isDefined(); }
	public abstract boolean isDefined();
	public abstract t get();
}