31
31
final class DiffOperation
32
32
{
33
33
private final Type type ;
34
- private final JsonPointer oldPointer ;
34
+ /* An op's "from", if any */
35
+ private final JsonPointer from ;
36
+ /* Value displaced by this operation, if any */
35
37
private final JsonNode oldValue ;
36
- private final JsonPointer newPointer ;
37
- private final JsonNode newValue ;
38
+ /* An op's "path", if any */
39
+ private final JsonPointer path ;
40
+ /* An op's "value", if any */
41
+ private final JsonNode value ;
38
42
39
- static DiffOperation add (final JsonPointer newPointer ,
40
- final JsonNode newValue )
43
+ static DiffOperation add (final JsonPointer path ,
44
+ final JsonNode value )
41
45
{
42
- return new DiffOperation (Type .ADD , null , null , newPointer , newValue );
46
+ return new DiffOperation (Type .ADD , null , null , path , value );
43
47
}
44
48
45
- static DiffOperation copy (final JsonPointer oldPointer ,
46
- final JsonPointer newPointer , final JsonNode newValue )
49
+ static DiffOperation copy (final JsonPointer from ,
50
+ final JsonPointer path , final JsonNode value )
47
51
{
48
- return new DiffOperation (Type .COPY , oldPointer , null , newPointer ,
49
- newValue );
52
+ return new DiffOperation (Type .COPY , from , null , path ,
53
+ value );
50
54
}
51
55
52
- static DiffOperation move (final JsonPointer oldPointer ,
53
- final JsonNode oldValue , final JsonPointer newPointer ,
54
- final JsonNode newValue )
56
+ static DiffOperation move (final JsonPointer from ,
57
+ final JsonNode oldValue , final JsonPointer path ,
58
+ final JsonNode value )
55
59
{
56
- return new DiffOperation (Type .MOVE , oldPointer , oldValue , newPointer ,
57
- newValue );
60
+ return new DiffOperation (Type .MOVE , from , oldValue , path ,
61
+ value );
58
62
}
59
63
60
- static DiffOperation remove (final JsonPointer oldPointer ,
64
+ static DiffOperation remove (final JsonPointer from ,
61
65
final JsonNode oldValue )
62
66
{
63
- return new DiffOperation (Type .REMOVE , oldPointer , oldValue , null , null );
67
+ return new DiffOperation (Type .REMOVE , from , oldValue , null , null );
64
68
}
65
69
66
- static DiffOperation replace (final JsonPointer oldPointer ,
67
- final JsonNode oldValue , final JsonNode newValue )
70
+ static DiffOperation replace (final JsonPointer from ,
71
+ final JsonNode oldValue , final JsonNode value )
68
72
{
69
- return new DiffOperation (Type .REPLACE , oldPointer , oldValue , null ,
70
- newValue );
73
+ return new DiffOperation (Type .REPLACE , from , oldValue , null ,
74
+ value );
71
75
}
72
76
73
- private DiffOperation (final Type type , final JsonPointer oldPointer ,
74
- final JsonNode oldValue , final JsonPointer newPointer ,
75
- final JsonNode newValue )
77
+ private DiffOperation (final Type type , final JsonPointer from ,
78
+ final JsonNode oldValue , final JsonPointer path ,
79
+ final JsonNode value )
76
80
{
77
81
this .type = type ;
78
- this .oldPointer = oldPointer ;
82
+ this .from = from ;
79
83
this .oldValue = oldValue ;
80
- this .newPointer = newPointer ;
81
- this .newValue = newValue ;
84
+ this .path = path ;
85
+ this .value = value ;
82
86
}
83
87
84
88
Type getType ()
85
89
{
86
90
return type ;
87
91
}
88
92
89
- JsonPointer getOldPointer ()
93
+ JsonPointer getFrom ()
90
94
{
91
- return oldPointer ;
95
+ return from ;
92
96
}
93
97
94
98
JsonNode getOldValue ()
95
99
{
96
100
return oldValue ;
97
101
}
98
102
99
- JsonPointer getNewPointer ()
103
+ JsonPointer getPath ()
100
104
{
101
- return newPointer ;
105
+ return path ;
102
106
}
103
107
104
- JsonNode getNewValue ()
108
+ JsonNode getValue ()
105
109
{
106
- return newValue ;
110
+ return value ;
107
111
}
108
112
109
113
JsonPatchOperation asJsonPatchOperation ()
@@ -117,39 +121,39 @@ enum Type {
117
121
@ Override
118
122
JsonPatchOperation toOperation (final DiffOperation op )
119
123
{
120
- return new AddOperation (op .newPointer , op .newValue );
124
+ return new AddOperation (op .path , op .value );
121
125
}
122
126
},
123
127
COPY
124
128
{
125
129
@ Override
126
130
JsonPatchOperation toOperation (final DiffOperation op )
127
131
{
128
- return new CopyOperation (op .oldPointer , op .newPointer );
132
+ return new CopyOperation (op .from , op .path );
129
133
}
130
134
},
131
135
MOVE
132
136
{
133
137
@ Override
134
138
JsonPatchOperation toOperation (final DiffOperation op )
135
139
{
136
- return new MoveOperation (op .oldPointer , op .newPointer );
140
+ return new MoveOperation (op .from , op .path );
137
141
}
138
142
},
139
143
REMOVE
140
144
{
141
145
@ Override
142
146
JsonPatchOperation toOperation (final DiffOperation op )
143
147
{
144
- return new RemoveOperation (op .oldPointer );
148
+ return new RemoveOperation (op .from );
145
149
}
146
150
},
147
151
REPLACE
148
152
{
149
153
@ Override
150
154
JsonPatchOperation toOperation (final DiffOperation op )
151
155
{
152
- return new ReplaceOperation (op .oldPointer , op .newValue );
156
+ return new ReplaceOperation (op .from , op .value );
153
157
}
154
158
},
155
159
;
0 commit comments