1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Torello.Java.JSON;

import java.util.function.ObjIntConsumer;
import javax.json.JsonValue;


// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Trivial Little Helper class that saves *A LOT* of typing!
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// 
// Remember, the only place anywhere inside of this entire JSON-Package where an actual reference 
// to an instance of "Lambdas<T>" is even possible is inside class 'TempFlags'
// 
// The class "SettingsRec" builds and instance of "Lambdas<T>", and passes that reference directly
// to the "TempFlags" constructor without saving any copies of that reference.  This class is used
// *STRICTLY* inside the "TempFlags" class, and then discarded immediately afterwards.
// 
// The primary purpose of this class is to, sort of, "LOCALIZE" a complete set of Functional
// Interfaces that are all, effectively, doing almost the same exact thing
// 
// 
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
//  Stale-Values Issue: EVERY FIELD IN 'SettingsRec' is 'final' (Except Field JsonArray ja)
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// 
// This means that the values passed to the parameters:
// 
//  * ACCEPTOR
//  * defaultValue
// 
// Won't "suddenly" change during the Processing of a User's Json-Array.  Once th SettingsRec has
// been constructed, the "ACCEPTOR" will simply NEVER CHANGE.
// 
// If this weren't the case, then ALL OF THESE LAMBDA'S WOULD BECOME OUT-OF-DATE, AND STALE 
// THE MINUTE THAT THE "ACCEPTOR" OR THE "defaultValue" CHANGED.
// 
// 
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// This class is used in:
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// 
// * Constructed (once) in SettingsRec<>, passed, immediately, as a parameter to 'TempFlags'
// * TempFlags -> Many (but not all) User-Provided FLAGS are converted to these handlers

class Lambdas<T>
{
    private final ObjIntConsumer<T> ACCEPTOR;
    private final T                 defaultValue;

    Lambdas(final ObjIntConsumer<T> ACCEPTOR, final T defaultValue)
    {
        this.ACCEPTOR       = ACCEPTOR;
        this.defaultValue   = defaultValue;
    }


    // If an "IntConsumer" is needed, the "Automatic Type-Inference Logic" will use one of these 
    // three methods.

    void AN(int i)      { this.ACCEPTOR.accept(null, i); }
    void AD(int i)      { this.ACCEPTOR.accept(defaultValue, i); }
    void NOOP(int i)    { }


    // If an "ObjIntConsumer" is needed, the "Auto Type-Chooser Dealy" will select one of these
    // three methods.

    void AN(JsonValue jv, int i)    { this.ACCEPTOR.accept(null, i); }
    void AD(JsonValue jv, int i)    { this.ACCEPTOR.accept(defaultValue, i); }
    void NOOP(JsonValue jv, int i)  { }
}