Package Torello.Java.JSON
Class ProcessMultiDimJsonArray
- java.lang.Object
-
- Torello.Java.JSON.ProcessMultiDimJsonArray
-
public class ProcessMultiDimJsonArray extends java.lang.Object
Hi-Lited Source-Code:- View Here: Torello/Java/JSON/ProcessMultiDimJsonArray.java
- Open New Browser-Tab: Torello/Java/JSON/ProcessMultiDimJsonArray.java
File Size: 6,227 Bytes Line Count: 158 '\n' Characters Found
-
-
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_TYPEjsonArrayToJava(JsonArray ja, SettingsRec<BASIC_TYPE,STREAM_TYPE> rec, Class<RETURN_ARR_TYPE> retArrClass)
-
-
-
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 classRJArrDimN
- 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 asint[][].class
or (in the case of Boxed-Type Arrays)Integer[][]
.- Parameters:
ja
- Any instance ofJsonArray
. The contents sof this array should match the dimensionality of the expected Output-Array Type, or an exception will likelyy throw.rec
- An instance ofSettingsRec
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 dimensionsexpectedRootClass
- The expected "root class". Forint[][].class
, the root class would beint.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;
-
-