File tree 3 files changed +32
-6
lines changed
java-diff-utils/src/main/java/com/github/difflib/patch
3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ public DeltaType getType() {
54
54
* @param target
55
55
* @throws PatchFailedException
56
56
*/
57
- protected void verifyChunk (List <T > target ) throws PatchFailedException {
58
- getSource ().verify (target );
57
+ protected VerifyChunk verifyChunkToFitTarget (List <T > target ) throws PatchFailedException {
58
+ return getSource ().verifyChunk (target );
59
59
}
60
60
61
61
public abstract void applyTo (List <T > target ) throws PatchFailedException ;
Original file line number Diff line number Diff line change @@ -92,16 +92,16 @@ public Chunk(int position, T[] lines) {
92
92
* @param target the sequence to verify against.
93
93
* @throws com.github.difflib.patch.PatchFailedException
94
94
*/
95
- public void verify (List <T > target ) throws PatchFailedException {
95
+ public VerifyChunk verifyChunk (List <T > target ) throws PatchFailedException {
96
96
if (position > target .size () || last () > target .size ()) {
97
- throw new PatchFailedException ( "Incorrect Chunk: the position of chunk > target size" ) ;
97
+ return VerifyChunk . POSITION_OUT_OF_TARGET ;
98
98
}
99
99
for (int i = 0 ; i < size (); i ++) {
100
100
if (!target .get (position + i ).equals (lines .get (i ))) {
101
- throw new PatchFailedException (
102
- "Incorrect Chunk: the chunk content doesn't match the target" );
101
+ return VerifyChunk .CONTENT_DOES_NOT_MATCH_TARGET ;
103
102
}
104
103
}
104
+ return VerifyChunk .OK ;
105
105
}
106
106
107
107
/**
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 java-diff-utils.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package com .github .difflib .patch ;
17
+
18
+ /**
19
+ *
20
+ * @author tw
21
+ */
22
+ public enum VerifyChunk {
23
+ OK ,
24
+ POSITION_OUT_OF_TARGET ,
25
+ CONTENT_DOES_NOT_MATCH_TARGET
26
+ }
You can’t perform that action at this time.
0 commit comments