Class ProcessMultiDimJsonArray

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method
      protected static <T> Class<T> CHECK_ARRAY_CLASS​(Class<T> retArrClass, Class<?> expectedRootClass)
      static <BASIC_TYPE,
           ​STREAM_TYPE,
           ​RETURN_ARR_TYPE>
      RETURN_ARR_TYPE
      jsonArrayToJava​(JsonArray ja, SettingsRec<BASIC_TYPE,​STREAM_TYPE> rec, Class<RETURN_ARR_TYPE> retArrClass)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • jsonArrayToJava

        🡇     🗕  🗗  🗖
        public static <BASIC_TYPE,​STREAM_TYPE,​RETURN_ARR_TYPE> RETURN_ARR_TYPE jsonArrayToJava​
                    (JsonArray ja,
                     SettingsRec<BASIC_TYPE,​STREAM_TYPE> rec,
                     java.lang.Class<RETURN_ARR_TYPE> retArrClass)
        
        This class is invoked by the class RJArrDimN
        Type Parameters:
        BASIC_TYPE - The "Component Type" of the Output-Array.
        STREAM_TYPE - The "Intermediate Stream Type", which is present before the conversion to an Array.
        RETURN_ARR_TYPE - The actual Return-Type of the method. This must be an Array-Class, such as int[][].class or (in the case of Boxed-Type Arrays) Integer[][].
        Parameters:
        ja - Any instance of JsonArray. The contents sof this array should match the dimensionality of the expected Output-Array Type, or an exception will likelyy throw.
        rec - An instance of SettingsRec that's been configured to return a multi-dimensional array.
        retArrClass - The class of the return array.
        Returns:
        An instance of 'retArrClass'
        Code:
        Exact Method Body:
         CHECK_ARRAY_CLASS(retArrClass, rec.CLASS);
         return jsonArrayToJava_INTERNAL(ja, rec, retArrClass);
        
      • CHECK_ARRAY_CLASS

        🡅     🗕  🗗  🗖
        protected static <T> java.lang.Class<T> CHECK_ARRAY_CLASS​
                    (java.lang.Class<T> retArrClass,
                     java.lang.Class<?> expectedRootClass)
        
        Check user input, and throws exceptions if the array-class has not been properly chosen.
        Parameters:
        retArrClass - This must be a primitive-array class, possibly of multiple dimensions
        expectedRootClass - The expected "root class". For int[][].class, the root class would be int.class.
        Returns:
        Parameter retArrClass is the return value of this checker method
        Throws:
        IllegalArgumentExcetion - If parameter retArrClass: If calling retArrClass.isArray() returns FALSE If the root-array type is not the appropriate type for the method that was called
        Code:
        Exact Method Body:
         Objects.requireNonNull(retArrClass, "Return-Array Type, Parameter 'retArrClass' is null");
        
         if (! retArrClass.isArray()) throw new IllegalArgumentException(
             "The class you have passed to parameter 'retArrClass' " +
             "[" + retArrClass.getSimpleName() + "], is not an array"
         );
        
         Class<?> componentClass = retArrClass.getComponentType();
        
         while (componentClass.isArray()) componentClass = componentClass.getComponentType();
        
         if (! expectedRootClass.equals(componentClass)) throw new IllegalArgumentException(
             "The class you have passed to parameter 'retArrClass' " +
             "[" + retArrClass.getSimpleName() + "], is not a(n) " +
             expectedRootClass.getSimpleName() + "-array."
         );
        
         return retArrClass;