001package Torello.JSON;
002
003import static javax.json.JsonValue.ValueType.OBJECT;
004
005import javax.json.*;
006
007import Torello.JSON.JsonBindingArrException;
008
009/**
010 * Used to indicate that one of the elements within a {@link JsonArray} was a parsed or valid
011 * {@link JsonObject}, but either a User-Provided Builder-Function, or a
012 * {@code JsonObject}-Constructor, has failed to build a POJO instance (using the extracted
013 * {@code JsonObject}) and has thrown instead.
014 * 
015 * <EMBED CLASS=globalDefs DATA-STRUCT=JsonArray DATA-TYPE=Array DATA-TYPE_ABBREV=Arr>
016 * <EMBED CLASS='external-html' DATA-FILE-ID=JE_FIELD_ARR>
017 * <EMBED CLASS='external-html' DATA-FILE-ID=JE_MSG>
018 * <EMBED CLASS='external-html' DATA-FILE-ID=JE_MSG_JBPAEX>
019 */
020@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="JE_BP_UL")
021@Torello.JavaDoc.Annotations.CSSLinks(FileNames="JSONExceptions.css")
022public class JsonBuildPOJOArrException extends JsonBindingArrException
023{
024    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX>  */
025    public static final long serialVersionUID = 1;
026
027    /**
028     * Constructs a {@code JsonBuildPOJOArrException} with no specified detail messsage,
029     * and the user-provided convenience-field values.
030     * 
031     * @param cause The exception thrown by the user-provided constructor or builder function
032     * @param errorSourceJsonArray  <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA>
033     * @param index                 <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I>
034     * @param joRetrieved           <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_JO_RETRIEVED>
035     * @param methodReturnJavaType  <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT>
036     */
037    public JsonBuildPOJOArrException(
038            Throwable   cause,
039            JsonArray   errorSourceJsonArray,
040            int         index,
041            JsonObject  joRetrieved,
042            Class<?>    methodReturnJavaType
043        )
044    {
045        super(
046            cause,
047            errorSourceJsonArray,   // Source JsonArray
048            index,                  // Index of JsonObject, within that array
049            OBJECT,                 // Expected Type
050            joRetrieved,            // Encountered JsonObject which failed to build
051            methodReturnJavaType,   // User Requested POJO Type
052
053            "Constructing a POJO instance from a JsonArray-Element has thrown an exception"
054        );
055    }
056
057    /**
058     * Constructs a {@code JsonBuildPOJOArrException} with the specified detail message, and
059     * user-provided convenience-field values.
060     * 
061     * @param message the detail message.
062     * @param cause The exception thrown by the user-provided constructor or builder function
063     * @param errorSourceJsonArray  <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_ESJA>
064     * @param index                 <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_I>
065     * @param joRetrieved           <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_JO_RETRIEVED>
066     * @param methodReturnJavaType  <EMBED CLASS='external-html' DATA-FILE-ID=JBEX_MRJT>
067     */
068    public JsonBuildPOJOArrException(
069            String      message,
070            Throwable   cause,
071            JsonArray   errorSourceJsonArray,
072            int         index,
073            JsonObject  joRetrieved,
074            Class<?>    methodReturnJavaType
075        )
076    {
077        super(
078            message,
079            cause,
080            errorSourceJsonArray,   // Source JsonArray
081            index,                  // Index of JsonObject, within that array
082            OBJECT,                 // Expected Type
083            joRetrieved,            // Encountered JsonObject which failed to build
084            methodReturnJavaType    // User Requested POJO Type
085        );
086    }
087}