Package org.organicdesign.fp.oneOf
Class Option.Some<T>
- java.lang.Object
-
- org.organicdesign.fp.oneOf.Option.Some<T>
-
- All Implemented Interfaces:
Serializable
,Option<T>
public static class Option.Some<T> extends Object implements Option<T>
Represents the presence of a value, even if that value is null.- 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 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(@NotNull Fn1<T,U> has, @NotNull Fn0<U> hasNot)
Pass in a function to execute if its Some and another to execute if its None.<U> Option<U>
then(@NotNull Fn1<T,Option<U>> f)
If this is Some, Apply the given function, else return None.@NotNull String
toString()
-
-
-
Method Detail
-
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(@NotNull @NotNull Fn1<T,U> has, @NotNull @NotNull 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(@NotNull @NotNull 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.
-
-