Class Or.Bad<G,​B>

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

    public static final class Or.Bad<G,​B>
    extends Object
    implements Or<G,​B>
    Represents the presence of a Bad value (and absence of a Good).
    • 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 Object