Class None<T>

  • All Implemented Interfaces:
    java.io.Serializable, Option<T>

    public final class None<T>
    extends java.lang.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​(java.lang.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.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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.
        Specified by:
        get in interface Option<T>
      • getOrElse

        public T getOrElse​(T t)
        If this is Some, return the value wrapped in this Option. Otherwise, return the given value.
        Specified by:
        getOrElse in interface Option<T>
      • isSome

        public boolean isSome()
        Is this Some?
        Specified by:
        isSome in interface Option<T>
      • 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.
        Specified by:
        match in interface Option<T>
      • 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.
        Specified by:
        then in interface Option<T>
      • hashCode

        @Deprecated
        public int hashCode()
        Deprecated.
        Valid, but deprecated because it's usually an error to call this in client code.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        @Deprecated
        public boolean equals​(java.lang.Object other)
        Deprecated.
        Valid, but deprecated because it's usually an error to call this in client code.
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object