Package sbt.testing

Class OptionalThrowable

java.lang.Object
sbt.testing.OptionalThrowable
All Implemented Interfaces:
Serializable

public final class OptionalThrowable extends Object implements Serializable
An optional Throwable.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an OptionalThrowable containing no Throwable.
    Constructs an OptionalThrowable containing a Throwable.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    get()
    Returns the Throwable contained in this OptionalThrowable if defined, else throws IllegalStateException.
    int
     
    boolean
    Indicates whether this OptionalThrowable is "defined," i.e., contains a Throwable.
    boolean
    Indicates whether this OptionalThrowable is "empty," i.e., contains no Throwable.
     

    Methods inherited from class java.lang.Object

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

    • OptionalThrowable

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

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

    • 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 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:
      IllegalStateException - if this OptionalThrowable is not defined.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object