Class Or.Good<G,​B>

  • All Implemented Interfaces:
    Or<G,​B>
    Enclosing interface:
    Or<G,​B>

    public static final class Or.Good<G,​B>
    extends java.lang.Object
    implements Or<G,​B>
    Represents the presence of a Good value (and absence of a Bad).
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.organicdesign.fp.oneOf.Or

        Or.Bad<G,​B>, Or.Good<G,​B>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      B bad()
      Returns the bad value if this is a Bad, or throws an exception if this is a Good.
      boolean equals​(java.lang.Object other)
      G good()
      Returns the good value if this is a Good, or throws an exception if this is a Bad.
      int hashCode()
      boolean isBad()
      Returns true if this Or has a bad value.
      boolean isGood()
      Returns true if this Or has a good value.
      <R> R match​(Fn1<G,​R> fg, Fn1<B,​R> fb)
      Exactly one of these functions will be executed - determined by whether this is a Good or a Bad.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • isGood

        public boolean isGood()
        Returns true if this Or has a good value.
        Specified by:
        isGood in interface Or<G,​B>
      • isBad

        public boolean isBad()
        Returns true if this Or has a bad value.
        Specified by:
        isBad in interface Or<G,​B>
      • good

        public G good()
        Returns the good value if this is a Good, or throws an exception if this is a Bad.
        Specified by:
        good in interface Or<G,​B>
      • bad

        public B bad()
        Returns the bad value if this is a Bad, or throws an exception if this is a Good.
        Specified by:
        bad in interface Or<G,​B>
      • match

        public <R> R match​(Fn1<G,​R> fg,
                           Fn1<B,​R> fb)
        Exactly one of these functions will be executed - determined by whether this is a Good or a Bad.
        Specified by:
        match in interface Or<G,​B>
        Parameters:
        fg - the function to be executed if this OneOf stores the first type.
        fb - the function to be executed if this OneOf stores the second type.
        Returns:
        the return value of whichever function is executed.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • toString

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