public static interface UpdateConstraint.PartialJSON extends 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.
UpdateConstraint.Factory, UpdateConstraint.Operator, UpdateConstraint.PartialJSON
Modifier and Type | Method and Description |
---|---|
<V> UpdateConstraint.PartialJSON |
with(String pointer,
Class<V> valueClass,
V value)
Deprecated.
since 6.10
Rather use the |
UpdateConstraint.PartialJSON |
with(String pointer,
UpdateConstraint.Operator operator,
Object value)
Compares a location within the JSON topic value to a specified value.
|
UpdateConstraint.PartialJSON |
without(String pointer)
Require a specific position in the JSON object to be absent.
|
and, or
@Deprecated <V> UpdateConstraint.PartialJSON with(String pointer, Class<V> valueClass, V value)
Rather use the with(String, Operator, Object)
method with the IS
operator.
This is equivalent to calling with(String, Operator, Object)
with an operator of IS
.
V
- the value type of the value at the pointerpointer
- the pointer expressionvalueClass
- this parameter is no longer used and is ignoredvalue
- the valueIllegalArgumentException
- if the pointer
parameter
cannot be parsed as a JSON pointer or if the class of the
supplied value is not supportedUpdateConstraint.PartialJSON with(String pointer, UpdateConstraint.Operator operator, Object value)
If there is no value found at the specified pointer position, the constraint will be unsatisfied.
If a String
value is supplied and the operator is
EQ
or NE
, 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 than IS
) are not permitted with
String values.
If a number value (Integer
, Long
or Double
)
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 than IS
) can be used with such
number comparisons. Decimal numbers can be compared with integral
numbers so 1
is equal to 1.0
, "1"
, or
"1.0"
.
If a null
value is supplied and the operator is
EQ
or NE
, the topic value at
the given pointer will be compared to JSON null. Other operators
(other than IS
) are not permitted with a
null
value.
If a Boolean
value is supplied and the operator is
EQ
, 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 IS
operator is specified the supplied
value will be compared to the topic value for strict binary equality.
In this case the value must be of type String
,
Integer
, Long
, Double
, Bytes
, or
null
. This is slightly more efficient than the lenient
comparisons described above.
pointer
- a JSON
Pointer specifying the location of the value
in
the JSON object.operator
- the operator that determines the type of comparisonvalue
- the valueIllegalArgumentException
- if the pointer
parameter
cannot be parsed as a JSON pointer, the value
type is
not supported, or the operator is not compatible with the
value
typeUpdateConstraint.PartialJSON without(String pointer)
The pointer
is a
JSON Pointer syntax
reference that should have no value in the JSON object.
pointer
- the pointer expressionIllegalArgumentException
- if the pointer
parameter
cannot be parsed as a JSON pointerCopyright © 2024 DiffusionData Ltd. All Rights Reserved.