Package Torello.Java.JSON
Class RJArrBoxedConsumerRec
- java.lang.Object
-
- Torello.Java.JSON.RJArrBoxedConsumerRec
-
public class RJArrBoxedConsumerRec extends java.lang.Object
RJArrBoxedConsumerRec 🠞RJArr
- ReadJsonArray
This class is a helper class, used for reading data directly from an already parsedJsonArray
instance.
BoxedConsumer
- Data is sent to a Java-Consumer of a Boxed-Primitive Type.
Rec
- The methods in this class produce a pre-configuredSettingsRec
instance. Re-using a Configuration-Record can speed up processing when more than oneJsonArray
needs to be handled. This record should be used in conjunction with the classProcessJsonArray
to process multipleJsonArray's
, efficiently.
Generate a Pre-ConfiguredSettingsRec
instance which can handle Java Boxed-Primitives.
This class builds on the J2EE Standard 'Glass-Fish' JSON Processor
There are several JSON Parsers available, and even more implementations for serializing and de-serializing data to/from JSON. The tool included in the J2EE is available on GitHub, and that is the one used by the Java HTML JAR Library. (See:javax.json.*
)
Primary Classes Used:JsonArray
andJsonObject
This class generates the Pre-Packaged, Pre-ConfiguredSettingsRec
instances that may be used to optimize loops. Use the records that are produced by the methods in this class in conjunction with the classProcessJsonArray
to (more efficiently) process MultipleJsonArray's
with similar characteristics.
Optimize Loops:
For each method within this class, there are actually two different variants of what is, essentially, the exact same method. Methods in this class whose name ends with the letters'Rec'
are methods that will produce what is known as a 'Settings Record', (see classSettingsRec<T, U>
).
Every one of the Json-Processing classes (in this Json Java-Package) that begin with the letters'RJArr'
are classes which iterateJsonArray's
. First, the class does some form of processing and testing to ensure that the contents of the arrays are properly converted into standard Java-Types. After the elements of aJsonArray
are successfully processed, they are then sent to either a Java-Array
, aStream
or a User-ProvidedConsumer
.
In order to guarantee that there is a homogenous algorithm for processing these array indices, only four Java 'for
-loops' have actually been written. (These loops may be easily inspected by clicking on the'Hi-Lited Source-Code'
button inside of classProcessJsonArray
). In this class, in order to differentiate between aJsonArray
which is to be converted into a Javaint[]
-Array, and one which is to be placed into a Javalong[]
-Array, a particular "Settings Record" is constructed (which "configures" the loop's body).
If only one invocation of a method is needed, then using the method that ends with'Arr'
should be perfectly sufficient! If the methods in this class are going to be invoked from inside of a loop (or invoked many times), then it would be much wiser to, first, obtain an instance of theSettingsRec
, and then invoke the Array-Processing code yourself.
In this way, generating twice as many short-lived, ephemeral, object instances (that are immediately discarded, and then collected by the Garbage-Collector) can be avoided. To do this is quite simple. Please review the documentation for the methods in this class whose name ends with'Rec'
- and look at the example code provided for how to use them.
The Loop Optimized variants of the methods in this class are, very simple, two step procedures (as opposed to just a single method invocation).- First, generate an instance of the
SettingsRec
class. Make sure to heed to Generic-Type Parameters returned by the Settings-Record Generator-Method you have called. - Second, simply call the specified Json-Array Processing method from class
ProcessJsonArray
Method Parameters
Parameter Explanation <PRIMITIVE> defaultValue
When an appropriate JFlag
-Value is included in the mask, this Default-Value will be passed to the User-Provided Consumer in whichever Error-Circumstance has occured (as per the Flag-Value Name).
This Default-Value may be requested throughJFlag
-Values such as:RD_AEX
,RD_IOB
andRD_M
(among others). The'RD'
in these Flag's Names is an abbreviation for "Return Default-Value".
The Complete List of Flags which request that this Default-Value Parameter be employed under various Error-Circumstances may be viewed in the following link. The name of each of these flags attempts identify the type of Error-Situation to which it may be applied.
Default-Value Flagsint FLAGS
A Bit-Wise Flag-Mask that provides a means for configuring the Array-Processing Logic to properly handle several types of Error-Cases & potentatial, unexpected, array contents.
A Flag-Mask of'0'
requests that any Error-Situations which occur, should they crop up while processing the array, be handled by standard means - meaning by throwing one of the germaine Exception-Class.Function
<String, BOXED_TYPE>
optionalUserParserThis parameter can only serve a purpose when it is used in conjunction with a JFlag
-Vaule which explicity requests that JavaString
-Values be handled by a parser (rather than causing an exception to throw).
The two flags which may be employed to signal this Handler-Behavior are:RETURN_PARSE_ON_STR
andRP_S
(the latter being merely the abbreviated variant of the former).
If neither of these flags have been AND'ed into the Flag-Mask parameter ("FLAGS"
), then any function which is passed to this parameter ("optionalUserParser"
) is wholly ignored - simply because using aString
-Parser is not a "Default Behavior of this class' Array-Processing Logic.
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/Java/JSON/RJArrBoxedConsumerRec.java
- Open New Browser-Tab: Torello/Java/JSON/RJArrBoxedConsumerRec.java
File Size: 15,926 Bytes Line Count: 390 '\n' Characters Found
Build a Settings-Record, Helper Class:
- View Here: BASIC_TYPES.java
- Open New Browser-Tab: BASIC_TYPES.java
File Size: 27,692 Bytes Line Count: 586 '\n' Characters Found
Build a Settings-Record, Helper Class:
- View Here: SETTINGS_REC_BUILDER.java
- Open New Browser-Tab: SETTINGS_REC_BUILDER.java
File Size: 9,469 Bytes Line Count: 240 '\n' Characters Found
Build a Settings-Record, Helper Class:
- View Here: CHANGEABLE_CONSUMER.java
- Open New Browser-Tab: CHANGEABLE_CONSUMER.java
File Size: 2,223 Bytes Line Count: 65 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctional
Annotation may also be called 'The Spaghetti Report'.Static-Functional
classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@Stateless
Annotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 16 Method(s), 16 declared static
- 0 Field(s)
-
-
Method Summary
Generate a SettingsRec Instance which reads a Json-Array into a Java Boxed-Primitives Consumer Modifier and Type Method static SettingsRec<Boolean,Void>
booleanRec(boolean defaultValue, int FLAGS, Function<String,Boolean> optionalUserParser)
static SettingsRec<Byte,Void>
byteRec(byte defaultValue, int FLAGS, Function<String,Byte> optionalUserParser)
static SettingsRec<Double,Void>
doubleRec(double defaultValue, int FLAGS, Function<String,Double> optionalUserParser)
static SettingsRec<Float,Void>
floatRec(float defaultValue, int FLAGS, Function<String,Float> optionalUserParser)
static SettingsRec<Integer,Void>
intRec(int defaultValue, int FLAGS, Function<String,Integer> optionalUserParser)
static SettingsRec<Long,Void>
longRec(long defaultValue, int FLAGS, Function<String,Long> optionalUserParser)
static SettingsRec<Number,Void>
numberRec(Number defaultValue, int FLAGS, Function<String,Number> optionalUserParser)
static SettingsRec<Short,Void>
shortRec(short defaultValue, int FLAGS, Function<String,Short> optionalUserParser)
Generate a SettingsRec Instance which reads a Json-Array into a Boxed-Primitives Consumer, w/ Array-Indices Modifier and Type Method static SettingsRec<Boolean,Void>
booleanRec2(boolean defaultValue, int FLAGS, Function<String,Boolean> optionalUserParser)
static SettingsRec<Byte,Void>
byteRec2(byte defaultValue, int FLAGS, Function<String,Byte> optionalUserParser)
static SettingsRec<Double,Void>
doubleRec2(double defaultValue, int FLAGS, Function<String,Double> optionalUserParser)
static SettingsRec<Float,Void>
floatRec2(float defaultValue, int FLAGS, Function<String,Float> optionalUserParser)
static SettingsRec<Integer,Void>
intRec2(int defaultValue, int FLAGS, Function<String,Integer> optionalUserParser)
static SettingsRec<Long,Void>
longRec2(long defaultValue, int FLAGS, Function<String,Long> optionalUserParser)
static SettingsRec<Number,Void>
numberRec2(Number defaultValue, int FLAGS, Function<String,Number> optionalUserParser)
static SettingsRec<Short,Void>
shortRec2(short defaultValue, int FLAGS, Function<String,Short> optionalUserParser)
-
-
-
Method Detail
-
intRec
public static SettingsRec<java.lang.Integer,java.lang.Void> intRec (int defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Integer> optionalUserParser)
Create a SettingsRec Instance for a Boxed-Integer ConsumerGenerates: An Integer-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Integer, Void> rec = RJArrBoxedConsumerRec.intRec(0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Integer> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
shortRec
public static SettingsRec<java.lang.Short,java.lang.Void> shortRec (short defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Short> optionalUserParser)
Create a SettingsRec Instance for a Boxed Short-Integer ConsumerGenerates: A Short-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Short, Void> rec = RJArrBoxedConsumerRec.shortRec(0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Short> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
byteRec
public static SettingsRec<java.lang.Byte,java.lang.Void> byteRec (byte defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Byte> optionalUserParser)
Create a SettingsRec Instance for a Boxed-Byte ConsumerGenerates: A Byte-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Byte, Void> rec = RJArrBoxedConsumerRec.byteRec(0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Byte> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
longRec
public static SettingsRec<java.lang.Long,java.lang.Void> longRec (long defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Long> optionalUserParser)
Create a SettingsRec Instance for a Boxed Long-Integer ConsumerGenerates: A Long-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Long, Void> rec = RJArrBoxedConsumerRec.longRec(0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Long> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
doubleRec
public static SettingsRec<java.lang.Double,java.lang.Void> doubleRec (double defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Double> optionalUserParser)
Create a SettingsRec Instance for a Boxed-Double ConsumerGenerates: A Double-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Double, Void> rec = RJArrBoxedConsumerRec.doubleRec(0.0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Double> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
floatRec
public static SettingsRec<java.lang.Float,java.lang.Void> floatRec (float defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Float> optionalUserParser)
Create a SettingsRec Instance for a Boxed-Float ConsumerGenerates: A Float-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Float, Void> rec = RJArrBoxedConsumerRec.floatRec(0.0f, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Float> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
booleanRec
public static SettingsRec<java.lang.Boolean,java.lang.Void> booleanRec (boolean defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Boolean> optionalUserParser)
Create a SettingsRec Instance for a Boxed-Boolean ConsumerGenerates: A Boolean-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.booleanToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Boolean, Void> rec = RJArrBoxedConsumerRec.booleanRec(false, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Boolean> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.booleanToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
numberRec
public static SettingsRec<java.lang.Number,java.lang.Void> numberRec (java.lang.Number defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Number> optionalUserParser)
Create a SettingsRec Instance for a (Best Filt) Boxed-Number ConsumerGenerates: A Number-Retrieval Settings-Record. Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.Value: Generating the internally used SettingsRec
Object-Instance yourself makes code more efficient. In this way, the object is constructed only once, rather than each time a new array is to be processed.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Number, Void> rec = RJArrBoxedConsumerRec.intRec(0, 0, null); for (JsonArray ja : someJsonArraySource) { // Create a new Consumer, make sure to use the Double-Colon '::' Syntax Here final List<Number> list = new List<>(); rec.setConsumer(list::add); // Process the Json-Array, and send the results to the consumer ProcessJsonArray.numericToJava(ja, rec); // The list has been properly populated, so now use the results doSomethingWith(list); }
-
intRec2
public static SettingsRec<java.lang.Integer,java.lang.Void> intRec2 (int defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Integer> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed-Integers, w/ Array-IndicesGenerates: An Integer-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Integer, Void> rec = RJArrBoxedConsumerRec.intRec2(1, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Integer> c = (int jsonArrayIndex, int successCount, Integer value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
shortRec2
public static SettingsRec<java.lang.Short,java.lang.Void> shortRec2 (short defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Short> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed Short-Integers, w/ Array-IndicesGenerates: A Short-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Short, Void> rec = RJArrBoxedConsumerRec.shortRec2(1, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Short> c = (int jsonArrayIndex, int successCount, Short value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
byteRec2
public static SettingsRec<java.lang.Byte,java.lang.Void> byteRec2 (byte defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Byte> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed-Bytes, w/ Array-IndicesGenerates: A Byte-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Byte, Void> rec = RJArrBoxedConsumerRec.byteRec2(1, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Byte> c = (int jsonArrayIndex, int successCount, Byte value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
longRec2
public static SettingsRec<java.lang.Long,java.lang.Void> longRec2 (long defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Long> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed Long-Integers, w/ Array-IndicesGenerates: A Long-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Long, Void> rec = RJArrBoxedConsumerRec.longRec2(1, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Long> c = (int jsonArrayIndex, int successCount, Long value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
doubleRec2
public static SettingsRec<java.lang.Double,java.lang.Void> doubleRec2 (double defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Double> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed-Doubles, w/ Array-IndicesGenerates: A Double-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Double, Void> rec = RJArrBoxedConsumerRec.doubleRec2(1.0, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Double> c = (int jsonArrayIndex, int successCount, Double value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
floatRec2
public static SettingsRec<java.lang.Float,java.lang.Void> floatRec2 (float defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Float> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed-Floats, w/ Array-IndicesGenerates: A Float-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Float, Void> rec = RJArrBoxedConsumerRec.floatRec2(1.0f, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Float> c = (int jsonArrayIndex, int successCount, Float value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
booleanRec2
public static SettingsRec<java.lang.Boolean,java.lang.Void> booleanRec2 (boolean defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Boolean> optionalUserParser)
Create a SettingsRec Instance for a Consumer of Boxed-Booleans, w/ Array-IndicesGenerates: A Boolean-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.booleanToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Boolean, Void> rec = RJArrBoxedConsumerRec.booleanRec2(false, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Boolean> c = (int jsonArrayIndex, int successCount, Boolean value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.booleanToJava(ja, rec);
-
numberRec2
public static SettingsRec<java.lang.Number,java.lang.Void> numberRec2 (java.lang.Number defaultValue, int FLAGS, java.util.function.Function<java.lang.String,java.lang.Number> optionalUserParser)
Create a SettingsRec Instance for a Consumer of (Best-Fit) Boxed-Numbers, w/ Array-IndicesGenerates: A Number-Retrieval Settings-Record, w/ an "Array-Indices & Count Consumer" Used For: The record produced from this method may be used as a parameter to invoke: Method ProcessJsonArray.numericToJava(JsonArray, SettingsRec)
See: Class JFlag
for information about the'FLAGS'
parameter.
Example:
// Generate a new & re-useable SettingsRec (Make less work for the G.C.) final SettingsRec<Number, Void> rec = RJArrBoxedConsumerRec.numberRec2(1, 0, null); // Create a Simple "Print the Values & Counts" Consumer. final IntIntTConsumer<Number> c = (int jsonArrayIndex, int successCount, Number value) -> System.out.println ("arrPos: " + jsonArrayIndex + ", count: " + successCount + ", value: " + value) // You must provide a consumer. The Double-Colon '::' Syntax is not required here. rec.setConsumer(c); // Re-Uses the Same SettingsRec instance. Also reuses the exact same Printing-Consumer for (JsonArray ja : someJsonArraySource) ProcessJsonArray.numericToJava(ja, rec);
-
-