001package com.identityworksllc.iiq.common.vo;
002
003import com.fasterxml.jackson.annotation.JsonAutoDetect;
004import com.fasterxml.jackson.annotation.JsonProperty;
005import com.fasterxml.jackson.databind.annotation.JsonSerialize;
006
007import java.io.Serializable;
008
009/**
010 * A container object holding a failure, usually in a threaded context
011 * @param <T> The type of the object that failed to be processed
012 * @param <E> The error type
013 */
014@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
015public class Failure<T, E extends Exception> implements Serializable {
016    private final E exception;
017
018    private final T object;
019
020    public Failure(T object, E exception) {
021        this.object = object;
022        this.exception = exception;
023    }
024
025    @JsonSerialize(using = ThrowableSerializer.class)
026    @JsonProperty("exception")
027    public E getException() {
028        return exception;
029    }
030
031    @JsonProperty("object")
032    public T getObject() {
033        return object;
034    }
035}