- All Known Subinterfaces:
Body
,Formdata
,QueryString
Unified API for HTTP value. This API plays two role:
- unify access to HTTP values, like query, path, form and header parameter - works as validation API, because it is able to check for required and type-safe values
The value API is composed by three types:
- Single value - Object value - Sequence of values (array)
Single value are can be converted to string, int, boolean, enum like values. Object value is a key:value structure (like a hash). Sequence of values are index based structure.
All these 3 types are modeled into a single Value class. At any time you can treat a value as 1) single, 2) hash or 3) array of them.
- Since:
- 2.0.0
- Author:
- edgar
-
Method Summary
Modifier and TypeMethodDescriptionget
(int index) Get a value at the given position.Get a value that matches the given name.iterator()
Value iterator.default String
Process the given expression and resolve value references.default String
Process the given expression and resolve value references.default String
Process the given expression and resolve value references.default String
Process the given expression and resolve value references.default int
size()
The number of values this one has.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.jooby.Value
booleanValue, booleanValue, byteValue, byteValue, doubleValue, doubleValue, floatValue, floatValue, intValue, intValue, isArray, isMissing, isObject, isPresent, isSingle, longValue, longValue, name, to, toEnum, toEnum, toList, toList, toMap, toMultimap, toNullable, toOptional, toOptional, toSet, toSet, value, value, value, valueOrNull
-
Method Details
-
get
Get a value at the given position.- Parameters:
index
- Position.- Returns:
- A value at the given position.
-
get
Get a value that matches the given name.- Parameters:
name
- Field name.- Returns:
- Field value.
-
size
default int size()The number of values this one has. For single values size is0
.- Returns:
- Number of values. Mainly for array and hash values.
-
iterator
Value iterator. -
resolve
Process the given expression and resolve value references.Value value = Value.single("foo", "bar"); String output = value.resolve("${foo}"); System.out.println(output);
- Parameters:
expression
- Text expression.- Returns:
- Resolved text.
-
resolve
Process the given expression and resolve value references.Value value = Value.single("foo", "bar"); String output = value.resolve("${missing}", true); System.out.println(output);
- Parameters:
expression
- Text expression.ignoreMissing
- On missing values, keep the expression as it is.- Returns:
- Resolved text.
-
resolve
@NonNull default String resolve(@NonNull String expression, @NonNull String startDelim, @NonNull String endDelim) Process the given expression and resolve value references.Value value = Value.single("foo", "bar"); String output = value.resolve("<%missing%>", "<%", "%>"); System.out.println(output);
- Parameters:
expression
- Text expression.startDelim
- Start delimiter.endDelim
- End delimiter.- Returns:
- Resolved text.
-
resolve
@NonNull default String resolve(@NonNull String expression, boolean ignoreMissing, @NonNull String startDelim, @NonNull String endDelim) Process the given expression and resolve value references.Value value = Value.single("foo", "bar"); String output = value.resolve("<%missing%>", "<%", "%>"); System.out.println(output);
- Parameters:
expression
- Text expression.ignoreMissing
- On missing values, keep the expression as it is.startDelim
- Start delimiter.endDelim
- End delimiter.- Returns:
- Resolved text.
-