- All Superinterfaces:
AutoCloseable
When a tRPC client sends a request for a multi-argument method, it packs the arguments into a
JSON array (a tuple). This reader acts as a cursor over that array. The Jooby Annotation
Processor (APT) generates routing code that calls the next*() methods on this interface
sequentially, perfectly matching the order of parameters in the target Java method.
Zero-Boxing Performance:
To maximize throughput, this interface provides dedicated methods for extracting primitive
types (e.g., nextInt(String), nextBoolean(String)). This allows the underlying
JSON parser (like Jackson or AvajeJsonb) to read numbers and booleans directly off the byte
stream without ever boxing them into heap-allocated objects like Integer or
Boolean.
Because it holds resources (like an open JsonParser), it implements AutoCloseable and must be closed after the final argument is read.
-
Method Summary
Modifier and TypeMethodDescriptionbooleannextBoolean(String name) Reads the next token in the stream as a primitive boolean.doublenextDouble(String name) Reads the next token in the stream as a primitive 64-bit floating-point number.intReads the next token in the stream as a primitive 32-bit integer.booleannextIsNull(String name) Peeks at the next token in the JSON stream to determine if it is a literalnull.longReads the next token in the stream as a primitive 64-bit integer.<T> TnextObject(String name, TrpcDecoder<T> decoder) Reads the next token (which may be a complex JSON object or array) and deserializes it using a pre-resolved type decoder.nextString(String name) Reads the next token in the stream as a String.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
nextIsNull
Peeks at the next token in the JSON stream to determine if it is a literalnull.- Parameters:
name- The logical name of the parameter being evaluated (used for context or error reporting).- Returns:
trueif the next token is null;falseotherwise.
-
nextInt
Reads the next token in the stream as a primitive 32-bit integer.- Parameters:
name- The logical name of the parameter.- Returns:
- The extracted integer value.
-
nextLong
Reads the next token in the stream as a primitive 64-bit integer.- Parameters:
name- The logical name of the parameter.- Returns:
- The extracted long value.
-
nextBoolean
Reads the next token in the stream as a primitive boolean.- Parameters:
name- The logical name of the parameter.- Returns:
- The extracted boolean value.
-
nextDouble
Reads the next token in the stream as a primitive 64-bit floating-point number.- Parameters:
name- The logical name of the parameter.- Returns:
- The extracted double value.
-
nextString
Reads the next token in the stream as a String.- Parameters:
name- The logical name of the parameter.- Returns:
- The extracted String value, or
nullif the token is a JSON null.
-
nextObject
Reads the next token (which may be a complex JSON object or array) and deserializes it using a pre-resolved type decoder.This method delegates the heavy lifting of mapping arbitrary JSON structures to the underlying JSON engine (Jackson, Gson, etc.) via the provided
TrpcDecoder.- Type Parameters:
T- The target Java type.- Parameters:
name- The logical name of the parameter.decoder- The optimized decoder created during application startup to handle this specific type.- Returns:
- The fully deserialized Java object, or
nullif the token is a JSON null.
-