Class Failure<T,​E extends Exception>

  • Type Parameters:
    T - The type of the object that failed to be processed
    E - The error type
    All Implemented Interfaces:
    Serializable

    public class Failure<T,​E extends Exception>
    extends Object
    implements Serializable
    A container object holding a failure, usually used in a threaded context.

    This indicates that the operation processing the given object of type T failed with an exception of type E.

    The ThrowableSerializer is used to make these objects JSON-friendly, but the output cannot be converted back to a Failure.

    If the object of type T is not null, it must be serializable by Jackson, either by default, via annotations, or via some mix-in.

    See Also:
    Serialized Form
    • Constructor Detail

      • Failure

        public Failure​(T object)
        Constructs a new Failure with an object but no exception
        Parameters:
        object - The object
      • Failure

        public Failure​(E exception)
        Constructs a new Failure with an exception but no object
        Parameters:
        exception - the exception
      • Failure

        public Failure​(T object,
                       E exception)
        Constructs a new failure with both an object and an exception
        Parameters:
        object - the object
        exception - the exception
    • Method Detail

      • getException

        public E getException()
        Gets the stored exception if one exists
        Returns:
        The stored exception
      • getObject

        public T getObject()
        Gets the stored object if one exists
        Returns:
        The stored object