Class SettingsRec<T,​U>


  • public class SettingsRec<T,​U>
    extends java.lang.Object
    The purpose of this class is to conglomerate all Functional-Interface / Method-Pointers into a single Java-Class. This JSON-Package offers a suite of JsonArray Processing Methods, each of which begins with name / text "RJArr". The list of classes which are made available by this Json Helper-Package are listed, here, below:


    Note that every single method in each and every one of the above mentioned classes utilize & rely on the class ProcessJsonArray to actually extract the Json-Values that are present inside of the JsonArray that is passed by the user when invoking one of these methods. This "Main Loop Class" (ProcessJsonArray) actually has four variations for handling the data that is present inside of a JsonArray. Inside this class the four methods can handle:

    Data Kind ProcessJsonArray Method-Link
    Numeric-Data: numericToJava
    String-Data: strToJava
    Boolean-Data: booleanToJava
    Object-Data: booleanToJava

    What there is to know about this class 'SettingsRec' is that all of the User's Choices & Decisions, based on the input from the JFlag Flag-Mask is converted, piece-meal, into a series of internally represented Lambda's & Function-Pointers - all of which are stored & saved, internallly, inside the fields of this SettingsRec class. By first converting all of these decisions regarding the specifics of what is actually inside of the JsonArray that is to be processed are codified into these Functional-Interfaces. It is through the settings inside of this Record-Class that all processing of Json-Data is actually handled inside of the four methods provided by ProcessJsonArray.


    • Method Detail

      • setConsumer

        🡇     🗕  🗗  🗖
        public void setConsumer​(java.util.function.Consumer<T> c)
        Assign a value to the internally used consumer, to which JsonArray data is emitted
        Parameters:
        c - This parameter is a Consumer<T> which will be invoked once for each element of a JsonArray being processed. The generic type <T> must match the type parameter with which this SettingsRec<T> instance was constructed. For example:

        • If this SettingsRec was constructed for Integer, then this parameter must be a Consumer<Integer>.
        • If String, then this must be Consumer<String>.
        • If MyObject, then use Consumer<MyObject>, and so on.

        This is enforced by Java’s compile-time generic type checking and will produce an error if you attempt to pass a Consumer of an incorrect type. Still, it is important to ensure that the Consumer you provide is explicitly aware of the correct T to avoid confusion or unsafe casting logic inside your lambda or method reference.

        If you would like to register a java.util.function.IntConsumer instead (for performance reasons or simpler syntax), and if your T is Integer, you may pass your consumer using a double-colon method reference:

        Example:
        IntConsumer ic = (int i) -> System.out.println(i);
        settingsRec.setConsumer(ic::accept);
        




        This works because ic::accept is compatible with Consumer<Integer>, thanks to Java’s method reference auto-boxing from int to Integer.
        Throws:
        WrongModeException - If this SettingsRec instance was not configured to emit / output its data to a Consumer (of any variant), then this exception will throw on invocation of this method. This method is only valid in situations where this record was constructed to Process JsonArray data that is to be output to a Consumer.

        This exception will also throw if the type of Consumer which was used to generate this SettingsRec does not match the Type-Parameter of this Method-Signature.

        Supported Consumer Types for JSON Array Processing. You must invoke the method that has a Consumer-Parameter which matches the original-contents that were used to build this SettingsRec instance. View the two types of Java-Consumer's available, here, in the table below:
        CONSUMER TYPE DESCRIPTION OF PARAMETERS
        Consumer<T> The method will invoke the consumer with only the array element of type T. This is used when the output handler only needs the actual value from the JSON array, such as Integer, String, MyObject, etc.
        IntIntTConsumer<T> The method will invoke the consumer with three arguments:

        1. int jsonArrayIndex – The original index of the element within the JSON array

        2. int successCount – The number of valid elements processed so far (excluding skips)

        3. T element – The parsed JSON element

        This form is used when metadata such as the array index or processing count is needed during iteration, for logging, analysis, or structured output.
        Code:
        Exact Method Body:
         assertChangeableConsumer();
         this.changeableConsumer.setConsumer(c);
        
      • setConsumer

        🡅     🗕  🗗  🗖
        public void setConsumer​(IntIntTConsumer<T> c)
        Assign a value to the internally used consumer, to which JsonArray data is emitted
        Parameters:
        c - This parameter is an IntIntTConsumer<T> that will be invoked once for each element of a JsonArray. This consumer receives not only the JSON value, but also two additional metadata fields: the array index, and the count of successfully parsed (non-skipped) elements.

        The generic type <T> must match the SettingsRec<T> instance’s original type declaration. For example:
        • If this SettingsRec was constructed with Integer, then this parameter must be IntIntTConsumer<Integer>.
        • If String, then use IntIntTConsumer<String>, and so on.

        This compatibility is enforced by Java’s compile-time generic type system. Any type mismatch will cause a compile-time error.

        IntIntTConsumer is useful when you need not only the parsed JSON value, but also the index and position tracking metadata during iteration.

        Note: If you are only interested in the JSON values themselves, and not the extra metadata, you should consider using setConsumer(Consumer<T>) instead.
        Throws:
        WrongModeException - If this SettingsRec instance was not configured to emit / output its data to a Consumer (of any variant), then this exception will throw on invocation of this method. This method is only valid in situations where this record was constructed to Process JsonArray data that is to be output to a Consumer.

        This exception will also throw if the type of Consumer which was used to generate this SettingsRec does not match the Type-Parameter of this Method-Signature.

        Supported Consumer Types for JSON Array Processing. You must invoke the method that has a Consumer-Parameter which matches the original-contents that were used to build this SettingsRec instance. View the two types of Java-Consumer's available, here, in the table below:
        CONSUMER TYPE DESCRIPTION OF PARAMETERS
        Consumer<T> The method will invoke the consumer with only the array element of type T. This is used when the output handler only needs the actual value from the JSON array, such as Integer, String, MyObject, etc.
        IntIntTConsumer<T> The method will invoke the consumer with three arguments:

        1. int jsonArrayIndex – The original index of the element within the JSON array

        2. int successCount – The number of valid elements processed so far (excluding skips)

        3. T element – The parsed JSON element

        This form is used when metadata such as the array index or processing count is needed during iteration, for logging, analysis, or structured output.
        Code:
        Exact Method Body:
         assertChangeableConsumer();
         this.changeableConsumer.setConsumer(c);