Package Torello.JSON

Class JsonBuildPOJOObjException

  • All Implemented Interfaces:
    java.io.Serializable

    public class JsonBuildPOJOObjException
    extends JsonBindingObjException
    JsonBuildPOJOObjException 🠞
    • Json - This exception is thrown by the Json Reader Classes

    • BuildPOJO - A User-Provided builder function or a User-Provided Class-Constructor has actually thrown an exception while trying to build or generate a Java POJO using a JsonObject as input to its constructor or builder-lambda.

    • Obj - Since these exceptions contain 'convenience fields' which provide some simple data about the Json that caused the exception throw, and since the 'relevant information' about a JsonObject property and a JsonArray index are somewhat different - there are two different exceptions for them! (An Exception for Object's and an exception for Array's).

      This class reports errors & exceptions that occur when extracting a JsonObject from a JsonObject, but end-up causing the ensuing user-provided constructor or builder invocation to throw.

    • Exception - This class inherits class Exception
    Used to indicate that one of the properties within a JsonObject was a parsed or valid JsonObject, but a User-Provided Builder-Function, or a JsonObject-Constructor, has failed to build a POJO instance (using the extracted JsonObject) and has thrown instead.

    The following 'final' Convenience Fields are exported by this Exception Class:
    Inherited Field Field Type Inherited From
    propertyName java.lang.String JsonBindingObjException
    errorSourceJsonStruct JsonStructure JsonBindingException
    expectedJsonType JsonValue.ValueType JsonBindingException
    methodReturnJavaType java.lang.Class JsonBindingException
    valueRetrieved JsonValue JsonBindingException

    The main benefit of this complicated exception-class inheritance tree are the exception messages generated by this class. If any sub-class of JsonBindingException is thrown, it is guaranteed to produce as much detail as possible about which Json-Element has generated the error. Below is an example of what this class exception messages look like:

    Terminal Output:
    Exception in thread "main" Torello.JSON.JsonBuildPOJO --- Exception: ... [followed by stack-trace]
    See Also:
    Serialized Form


    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.

        Note that Java's java.lang.Exception and java.lang.Error classes implement the Serializable interface, and a warning-free build expects this field be defined here.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final long serialVersionUID = 1;
        
    • Constructor Detail

      • JsonBuildPOJOObjException

        🡅  🡇     🗕  🗗  🗖
        public JsonBuildPOJOObjException​(java.lang.Throwable cause,
                                         JsonObject errorSourceJsonObject,
                                         java.lang.String propertyName,
                                         JsonObject joRetrieved,
                                         java.lang.Class<?> methodReturnJavaType)
        Constructs a JsonBuildPOJOObjException with no specified detail messsage, and the user-provided convenience-field values.
        Parameters:
        cause - The exception thrown by the user-provided constructor or builder function
        errorSourceJsonObject - The JsonObject from which the property is being retrieved / extracted.
        propertyName - This is the property-name into the JsonObject from which the property is being retrieved / extracted.
        joRetrieved - A valid instance of JsonObject which has been properly extracted from either a JsonArray or a JsonObject. This must be the object which has caused the user-provided constructor or builder-lambda to throw.
        methodReturnJavaType - Class ReadJSON will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
      • JsonBuildPOJOObjException

        🡅     🗕  🗗  🗖
        public JsonBuildPOJOObjException​(java.lang.String message,
                                         java.lang.Throwable cause,
                                         JsonObject errorSourceJsonObject,
                                         java.lang.String propertyName,
                                         JsonObject joRetrieved,
                                         java.lang.Class<?> methodReturnJavaType)
        Constructs a JsonBuildPOJOObjException with the specified detail message, and user-provided convenience-field values.
        Parameters:
        message - the detail message.
        cause - The exception thrown by the user-provided constructor or builder function
        errorSourceJsonObject - The JsonObject from which the property is being retrieved / extracted.
        propertyName - This is the property-name into the JsonObject from which the property is being retrieved / extracted.
        joRetrieved - A valid instance of JsonObject which has been properly extracted from either a JsonArray or a JsonObject. This must be the object which has caused the user-provided constructor or builder-lambda to throw.
        methodReturnJavaType - Class ReadJSON will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.