Package sbt.testing

Class OptionalThrowable

  • All Implemented Interfaces:
    java.io.Serializable

    public final class OptionalThrowable
    extends java.lang.Object
    implements java.io.Serializable
    An optional Throwable.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      OptionalThrowable()
      Constructs an OptionalThrowable containing no Throwable.
      OptionalThrowable​(java.lang.Throwable exception)
      Constructs an OptionalThrowable containing a Throwable.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.Throwable get()
      Returns the Throwable contained in this OptionalThrowable if defined, else throws IllegalStateException.
      int hashCode()  
      boolean isDefined()
      Indicates whether this OptionalThrowable is "defined," i.e., contains a Throwable.
      boolean isEmpty()
      Indicates whether this OptionalThrowable is "empty," i.e., contains no Throwable.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • OptionalThrowable

        public OptionalThrowable​(java.lang.Throwable exception)
        Constructs an OptionalThrowable containing a Throwable.
      • OptionalThrowable

        public OptionalThrowable()
        Constructs an OptionalThrowable containing no Throwable.
    • Method Detail

      • isDefined

        public boolean isDefined()
        Indicates whether this OptionalThrowable is "defined," i.e., contains a Throwable.
        Returns:
        true if this OptionalThrowable contains a Throwable
      • isEmpty

        public boolean isEmpty()
        Indicates whether this OptionalThrowable is "empty," i.e., contains no Throwable.
        Returns:
        true if this OptionalThrowable contains no Throwable
      • get

        public java.lang.Throwable get()
        Returns the Throwable contained in this OptionalThrowable if defined, else throws IllegalStateException.

        To avoid the IllegalStateException, ensure isDefined returns true before calling this method.

        Returns:
        the contained Throwable, if this OptionalThrowable is defined
        Throws:
        java.lang.IllegalStateException - if this OptionalThrowable is not defined.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

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