Package com.ultikits.ultitools.utils
Class PayloadReader
java.lang.Object
com.ultikits.ultitools.utils.PayloadReader
Strict protocol payload reader shared by framework handlers; internal, not for module use.
Validation failures are unchecked and carry invalid_message plus the request id;
AgentMessageRouter converts them to correlated errors without exposing payload text.
JSON values are copied on input and access. Bounds are inclusive and strings are
measured in Unicode code points, as in the vendored JSON Schemas.
- Since:
- 6.3.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPayloadReader(String id, com.google.gson.JsonObject payload) Creates a reader over a defensive payload snapshot. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonArrayReads a required array; element validation remains the caller's responsibility.booleanReads a required boolean without string or number coercion.private BigDecimalReads a required string matching exactly one allowed value.longReads a required integral JSON number, rejecting fractional or overflowing values.private InvalidFrameExceptioninvalid()Rejects missing required keys and every key outside the two sets.doubleReads a required finite JSON number without string coercion.com.google.gson.JsonObjectReads a required object; its field validation remains the caller's responsibility.com.google.gson.JsonElementReads an optional key without imposing a value type.com.google.gson.JsonElementReads a required key without imposing a value type.Reads a required string without coercion from other JSON types.
-
Field Details
-
id
-
payload
private final com.google.gson.JsonObject payload
-
-
Constructor Details
-
PayloadReader
Creates a reader over a defensive payload snapshot.- Parameters:
id- the request envelope ULID for validation errorspayload- the non-null object to validate
-
-
Method Details
-
keys
Rejects missing required keys and every key outside the two sets.- Parameters:
required- names that must be present, even when their value is JSON nulloptional- additional allowed names- Returns:
- this reader; validate each value separately
-
required
Reads a required key without imposing a value type.- Parameters:
key- the field name- Returns:
- a deep copy, including JSON null when explicitly present
-
optional
Reads an optional key without imposing a value type.- Parameters:
key- the field name- Returns:
- a deep copy, or Java null only when absent
-
string
Reads a required string without coercion from other JSON types.- Parameters:
key- the field namemin- minimum code-point countmax- maximum code-point countpattern- full-string pattern, or null to skip pattern validation- Returns:
- the validated string
-
integer
Reads a required integral JSON number, rejecting fractional or overflowing values.- Parameters:
key- the field namemin- minimum allowed valuemax- maximum allowed value- Returns:
- the validated integer
-
number
Reads a required finite JSON number without string coercion.- Parameters:
key- the field namemin- minimum allowed valuemax- maximum allowed value- Returns:
- the validated number
-
decimal
-
bool
Reads a required boolean without string or number coercion.- Parameters:
key- the field name- Returns:
- the validated boolean
-
enumValue
Reads a required string matching exactly one allowed value.- Parameters:
key- the field namevalues- case-sensitive allowed values- Returns:
- the validated enum value
-
array
Reads a required array; element validation remains the caller's responsibility.- Parameters:
key- the field namemin- minimum item countmax- maximum item count- Returns:
- a deep copy of the validated array
-
object
Reads a required object; its field validation remains the caller's responsibility.- Parameters:
key- the field name- Returns:
- a deep copy of the object
-
invalid
-