Package org.organicdesign.fp.oneOf
Class None<T>
- java.lang.Object
-
- org.organicdesign.fp.oneOf.None<T>
-
- All Implemented Interfaces:
Serializable
,Option<T>
public final class None<T> extends Object implements Option<T>
Represents the absence of a value- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.oneOf.Option
Option.Some<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object other)
Deprecated.T
get()
Return the value wrapped in this Option.T
getOrElse(T t)
If this is Some, return the value wrapped in this Option.int
hashCode()
Deprecated.boolean
isSome()
Is this Some?<U> U
match(Fn1<T,U> has, Fn0<U> hasNot)
Pass in a function to execute if its Some and another to execute if its None.static <T> None<T>
none()
Generic version of the singleton instance.<U> Option<U>
then(Fn1<T,Option<U>> f)
If this is Some, Apply the given function, else return None.String
toString()
-
-
-
Method Detail
-
none
public static <T> None<T> none()
Generic version of the singleton instance.
-
get
public T get()
Return the value wrapped in this Option. Only safe to call this on Some.
-
getOrElse
public T getOrElse(T t)
If this is Some, return the value wrapped in this Option. Otherwise, return the given value.
-
match
public <U> U match(Fn1<T,U> has, Fn0<U> hasNot)
Pass in a function to execute if its Some and another to execute if its None.
-
then
public <U> Option<U> then(Fn1<T,Option<U>> f)
If this is Some, Apply the given function, else return None. Use this to chain options together, failing fast at the first none() or continuing through as many operations that return some as possible.
-
hashCode
@Deprecated public int hashCode()
Deprecated.Valid, but deprecated because it's usually an error to call this in client code.
-
equals
@Deprecated public boolean equals(Object other)
Deprecated.Valid, but deprecated because it's usually an error to call this in client code.
-
-