Interface UpdateConstraint.PartialJSON
- All Superinterfaces:
UpdateConstraint
- Enclosing interface:
- UpdateConstraint
JSON
topic to match the partially described value.
The code:
Constraint.Factory factory = Diffusion.updateConstraints();
PartialJSON constraint =
factory.jsonValue()
.with("/id", String.class, idValue)
.without("/cancellation");
creates a constraint for a JSON object with a specific ID value and no
value for a "cancellation" property.
Missing keys are matched differently to keys that are present with null values.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.pushtechnology.diffusion.client.features.UpdateConstraint
UpdateConstraint.Factory, UpdateConstraint.Operator, UpdateConstraint.PartialJSON -
Method Summary
Modifier and TypeMethodDescriptionwith(String pointer, UpdateConstraint.Operator operator, Object value) Compares a location within the JSON topic value to a specified value.Deprecated.since 6.10Require a specific position in the JSON object to be absent.Methods inherited from interface com.pushtechnology.diffusion.client.features.UpdateConstraint
and, or
-
Method Details
-
with
Deprecated.since 6.10Rather use the
with(String, Operator, Object)method with theISoperator.Require a value at a specific position in the JSON object.This is equivalent to calling
with(String, Operator, Object)with an operator ofIS.- Type Parameters:
V- the value type of the value at the pointer- Parameters:
pointer- the pointer expressionvalueClass- this parameter is no longer used and is ignoredvalue- the value- Returns:
- a new constraint
- Throws:
IllegalArgumentException- if thepointerparameter cannot be parsed as a JSON pointer or if the class of the supplied value is not supported
-
with
Compares a location within the JSON topic value to a specified value.If there is no value found at the specified pointer position, the constraint will be unsatisfied.
If a
Stringvalue is supplied and the operator isEQorNE, the string representation of the topic value at the given pointer will be compared to the supplied value. If the value at the pointer position is not a string or number the constraint will be unsatisfied. Other operators (other thanIS) are not permitted with String values.If a number value (
Integer,LongorDouble) is supplied the value will be compared with the number value at the topic location. This will work with JSON string or number values only. JSON strings can only be compared if they contain a value that can be parsed as a number. If a string value at the location cannot be parsed as a number, the constraint will be unsatisfied. Any of the operators (other thanIS) can be used with such number comparisons. Decimal numbers can be compared with integral numbers so1is equal to1.0,"1", or"1.0".If a
nullvalue is supplied and the operator isEQorNE, the topic value at the given pointer will be compared to JSON null. Other operators (other thanIS) are not permitted with anullvalue.If a
Booleanvalue is supplied and the operator isEQ, the topic value at the given pointer will be compared to the boolean value. Other operators are not permitted with a boolean value.If the
ISoperator is specified the supplied value will be compared to the topic value for strict binary equality. In this case the value must be of typeString,Integer,Long,Double,Bytes, ornull. This is slightly more efficient than the lenient comparisons described above.- Parameters:
pointer- a JSON Pointer specifying the location of thevaluein the JSON object.operator- the operator that determines the type of comparisonvalue- the value- Returns:
- a new constraint
- Throws:
IllegalArgumentException- if thepointerparameter cannot be parsed as a JSON pointer, thevaluetype is not supported, or the operator is not compatible with thevaluetype- Since:
- 6.10
-
without
Require a specific position in the JSON object to be absent. This does not match positions that have null values.The
pointeris a JSON Pointer syntax reference that should have no value in the JSON object.- Parameters:
pointer- the pointer expression- Returns:
- a new constraint
- Throws:
IllegalArgumentException- if thepointerparameter cannot be parsed as a JSON pointer
-