Enum JsonPatch.Operation
- java.lang.Object
-
- java.lang.Enum<JsonPatch.Operation>
-
- javax.json.JsonPatch.Operation
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<JsonPatch.Operation>
- Enclosing interface:
- JsonPatch
public static enum JsonPatch.Operation extends java.lang.Enum<JsonPatch.Operation>
An enumeration of available operations for
JsonPatch.
NOTICE: the behavoir of some operations depends on which
JsonValuethey are performed. for details please check the documentation of the very operation.- Since:
- 1.1
- See Also:
- RFC-6902
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ADDrequired members are: "op": "add" "path": "path/to/add" "value": "JsonValueToAdd"COPYrequired members are: "op": "copy" "from": "path/to/copy/from" "path": "path/to/add"MOVErequired members are: "op": "move" "from": "path/to/move/from" "path": "path/to/move/to"REMOVErequired members are: "op": "remove" "path": "path/to/remove"REPLACErequired members are: "op": "replace" "path": "path/to/replace" "value": "the newJsonValue"TESTrequired members are: "op": "test" "path": "/path/to/test" "value": "JsonValueto test"
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonPatch.OperationfromOperationName(java.lang.String operationName)Returns theJsonPatch.Operationfor the givenoperationName.java.lang.StringoperationName()static JsonPatch.OperationvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static JsonPatch.Operation[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ADD
public static final JsonPatch.Operation ADD
required members are:
- "op": "add"
- "path": "path/to/add"
- "value": "
JsonValueToAdd"
if the "path/to" does not exist, this operation will result in an error.
if the "path/to/add" already exists, the value will be replacedfor
JsonArrays the new value will be inserted at the specified index and the element(s) at/after are shifted to the right. the '-' character is used to append the value at the and of theJsonArray.
-
REMOVE
public static final JsonPatch.Operation REMOVE
required members are:
- "op": "remove"
- "path": "path/to/remove"
if the "path/to/remove" does not exist, the operation will fail.
for
JsonArrays the values after the removed value are shifted to the left
-
REPLACE
public static final JsonPatch.Operation REPLACE
-
MOVE
public static final JsonPatch.Operation MOVE
required members are:
- "op": "move"
- "from": "path/to/move/from"
- "path": "path/to/move/to"
the operation will fail it the "path/to/move/from" does not exist
NOTICE: a location can not be moved into one of it's children. (from /a/b/c to /a/b/c/d)
this operation is identical to
REMOVEfrom "from" andADDto the "path"
-
COPY
public static final JsonPatch.Operation COPY
required members are:
- "op": "copy"
- "from": "path/to/copy/from"
- "path": "path/to/add"
the operation will result in an error if the "from" location does not exist
this operation is identical to
ADDwith the "from" value
-
TEST
public static final JsonPatch.Operation TEST
required members are:
- "op": "test"
- "path": "/path/to/test"
- "value": "
JsonValueto test"
this operation fails, if the value is NOT equal with the /path/to/test
ordering of the elements in a
JsonObjectis NOT significant however the position of an element in aJsonArrayis significant for equality.
-
-
Method Detail
-
values
public static JsonPatch.Operation[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JsonPatch.Operation c : JsonPatch.Operation.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JsonPatch.Operation valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
operationName
public java.lang.String operationName()
- Returns:
- the JSON operation name
-
fromOperationName
public static JsonPatch.Operation fromOperationName(java.lang.String operationName)
Returns theJsonPatch.Operationfor the givenoperationName. If noJsonPatch.Operationis present, aJsonExceptionwill be thrown.- Parameters:
operationName-operationNameto convert to the enum constant.- Returns:
- the
Operation-constantfor givenoperationName - Throws:
JsonException- if noJsonPatch.Operationhas been found for the givenoperationName
-
-