Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc5ecb8

Browse files
committed
fixes#159
1 parent4cad0ea commitdc5ecb8

File tree

11 files changed

+41
-40
lines changed

11 files changed

+41
-40
lines changed

‎CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on[Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project uses a custom versioning scheme (and not[Semantic Versioning](https://semver.org/spec/v2.0.0.html)).
77

8-
##[unreleased]
8+
##[4.13]
9+
10+
* API change: due to Issue#159: the author of the algorithm is Eugene Myers, therefore classes and methods were renamed accordingly
911

1012
###Changed
1113

‎java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
importcom.github.difflib.algorithm.DiffAlgorithmFactory;
1919
importcom.github.difflib.algorithm.DiffAlgorithmI;
2020
importcom.github.difflib.algorithm.DiffAlgorithmListener;
21-
importcom.github.difflib.algorithm.myers.MeyersDiff;
21+
importcom.github.difflib.algorithm.myers.MyersDiff;
2222
importcom.github.difflib.patch.AbstractDelta;
2323
importcom.github.difflib.patch.Patch;
2424
importcom.github.difflib.patch.PatchFailedException;
@@ -37,7 +37,7 @@ public final class DiffUtils {
3737
/**
3838
* This factory generates the DEFAULT_DIFF algorithm for all these routines.
3939
*/
40-
staticDiffAlgorithmFactoryDEFAULT_DIFF =MeyersDiff.factory();
40+
staticDiffAlgorithmFactoryDEFAULT_DIFF =MyersDiff.factory();
4141

4242
publicstaticvoidwithDefaultDiffAlgorithmFactory(DiffAlgorithmFactoryfactory) {
4343
DEFAULT_DIFF =factory;
@@ -95,7 +95,7 @@ public static <T> Patch<T> diff(List<T> source, List<T> target,
9595
returnDiffUtils.diff(source,target,
9696
DEFAULT_DIFF.create(equalizer));
9797
}
98-
returnDiffUtils.diff(source,target,newMeyersDiff<>());
98+
returnDiffUtils.diff(source,target,newMyersDiff<>());
9999
}
100100

101101
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MeyersDiff.javarenamed to ‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
importjava.util.function.BiPredicate;
2828

2929
/**
30-
* A clean-room implementation of EugeneMeyers greedy differencing algorithm.
30+
* A clean-room implementation of EugeneMyers greedy differencing algorithm.
3131
*/
32-
publicfinalclassMeyersDiff<T>implementsDiffAlgorithmI<T> {
32+
publicfinalclassMyersDiff<T>implementsDiffAlgorithmI<T> {
3333

3434
privatefinalBiPredicate<T,T>equalizer;
3535

36-
publicMeyersDiff() {
36+
publicMyersDiff() {
3737
equalizer =Object::equals;
3838
}
3939

40-
publicMeyersDiff(finalBiPredicate<T,T>equalizer) {
40+
publicMyersDiff(finalBiPredicate<T,T>equalizer) {
4141
Objects.requireNonNull(equalizer,"equalizer must not be null");
4242
this.equalizer =equalizer;
4343
}
@@ -187,13 +187,13 @@ public static DiffAlgorithmFactory factory() {
187187
@Override
188188
public <T>DiffAlgorithmI<T>
189189
create() {
190-
returnnewMeyersDiff<T>();
190+
returnnewMyersDiff<T>();
191191
}
192192

193193
@Override
194194
public <T>DiffAlgorithmI<T>
195195
create(BiPredicate <T,T >equalizer) {
196-
returnnewMeyersDiff<T>(equalizer);
196+
returnnewMyersDiff<T>(equalizer);
197197
}
198198
};
199199
}

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MeyersDiffWithLinearSpace.javarenamed to ‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
*
3131
* @author tw
3232
*/
33-
publicclassMeyersDiffWithLinearSpace<T>implementsDiffAlgorithmI<T> {
33+
publicclassMyersDiffWithLinearSpace<T>implementsDiffAlgorithmI<T> {
3434

3535
privatefinalBiPredicate<T,T>equalizer;
3636

37-
publicMeyersDiffWithLinearSpace() {
37+
publicMyersDiffWithLinearSpace() {
3838
equalizer =Object::equals;
3939
}
4040

41-
publicMeyersDiffWithLinearSpace(finalBiPredicate<T,T>equalizer) {
41+
publicMyersDiffWithLinearSpace(finalBiPredicate<T,T>equalizer) {
4242
Objects.requireNonNull(equalizer,"equalizer must not be null");
4343
this.equalizer =equalizer;
4444
}
@@ -231,13 +231,13 @@ public static DiffAlgorithmFactory factory() {
231231
@Override
232232
public <T>DiffAlgorithmI<T>
233233
create() {
234-
returnnewMeyersDiffWithLinearSpace<T>();
234+
returnnewMyersDiffWithLinearSpace<T>();
235235
}
236236

237237
@Override
238238
public <T>DiffAlgorithmI<T>
239239
create(BiPredicate <T,T >equalizer) {
240-
returnnewMeyersDiffWithLinearSpace<T>(equalizer);
240+
returnnewMyersDiffWithLinearSpace<T>(equalizer);
241241
}
242242
};
243243
}

‎java-diff-utils/src/test/java/com/github/difflib/DiffUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void testDiffMissesChangeForkDnaumenkoIssue31() {
132132
}
133133

134134
/**
135-
* To test this, the greedymeyer algorithm is not suitable.
135+
* To test this, the greedyMyer algorithm is not suitable.
136136
*/
137137
@Test
138138
@Disabled

‎java-diff-utils/src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class MyersDiffTest {
3434
publicvoidtestDiffMyersExample1Forward() {
3535
List<String>original =Arrays.asList("A","B","C","A","B","B","A");
3636
List<String>revised =Arrays.asList("C","B","A","B","A","C");
37-
finalPatch<String>patch =Patch.generate(original,revised,newMeyersDiff<String>().computeDiff(original,revised,null));
37+
finalPatch<String>patch =Patch.generate(original,revised,newMyersDiff<String>().computeDiff(original,revised,null));
3838
assertNotNull(patch);
3939
assertEquals(4,patch.getDeltas().size());
4040
assertEquals("Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [InsertDelta, position: 3, lines: [B]], [DeleteDelta, position: 5, lines: [B]], [InsertDelta, position: 7, lines: [C]]]}",patch.toString());
@@ -47,7 +47,7 @@ public void testDiffMyersExample1ForwardWithListener() {
4747

4848
List<String>logdata =newArrayList<>();
4949
finalPatch<String>patch =Patch.generate(original,revised,
50-
newMeyersDiff<String>().computeDiff(original,revised,newDiffAlgorithmListener() {
50+
newMyersDiff<String>().computeDiff(original,revised,newDiffAlgorithmListener() {
5151
@Override
5252
publicvoiddiffStart() {
5353
logdata.add("start");

‎java-diff-utils/src/test/java/com/github/difflib/algorithm/myers/MeyersDiffWithLinearSpaceTest.javarenamed to ‎java-diff-utils/src/test/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpaceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
*
3131
* @author tw
3232
*/
33-
publicclassMeyersDiffWithLinearSpaceTest {
33+
publicclassMyersDiffWithLinearSpaceTest {
3434

3535
@Test
3636
publicvoidtestDiffMyersExample1Forward() {
3737
List<String>original =Arrays.asList("A","B","C","A","B","B","A");
3838
List<String>revised =Arrays.asList("C","B","A","B","A","C");
39-
finalPatch<String>patch =Patch.generate(original,revised,newMeyersDiffWithLinearSpace<String>().computeDiff(original,revised,null));
39+
finalPatch<String>patch =Patch.generate(original,revised,newMyersDiffWithLinearSpace<String>().computeDiff(original,revised,null));
4040
assertNotNull(patch);
4141
System.out.println(patch);
4242
assertEquals(5,patch.getDeltas().size());
@@ -50,7 +50,7 @@ public void testDiffMyersExample1ForwardWithListener() {
5050

5151
List<String>logdata =newArrayList<>();
5252
finalPatch<String>patch =Patch.generate(original,revised,
53-
newMeyersDiffWithLinearSpace<String>().computeDiff(original,revised,newDiffAlgorithmListener() {
53+
newMyersDiffWithLinearSpace<String>().computeDiff(original,revised,newDiffAlgorithmListener() {
5454
@Override
5555
publicvoiddiffStart() {
5656
logdata.add("start");
@@ -84,7 +84,7 @@ public void testPerformanceProblemsIssue124() {
8484
.collect(toList());
8585

8686
longstart =System.currentTimeMillis();
87-
Patch<String>diff =DiffUtils.diff(old,newl,newMeyersDiffWithLinearSpace<String>());
87+
Patch<String>diff =DiffUtils.diff(old,newl,newMyersDiffWithLinearSpace<String>());
8888
longend =System.currentTimeMillis();
8989
System.out.println("Finished in " + (end -start) +"ms and resulted " +diff.getDeltas().size() +" deltas");
9090
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
importcom.github.difflib.DiffUtils;
2424

25-
publicclassWithMeyersDiffWithLinearSpacePatchTest {
25+
publicclassWithMyersDiffWithLinearSpacePatchTest {
2626

2727
@Test
2828
publicvoidtestPatch_Insert() {
2929
finalList<String>insertTest_from =Arrays.asList("hhh");
3030
finalList<String>insertTest_to =Arrays.asList("hhh","jjj","kkk","lll");
3131

32-
finalPatch<String>patch =DiffUtils.diff(insertTest_from,insertTest_to,newMeyersDiffWithLinearSpace<String>());
32+
finalPatch<String>patch =DiffUtils.diff(insertTest_from,insertTest_to,newMyersDiffWithLinearSpace<String>());
3333
try {
3434
assertEquals(insertTest_to,DiffUtils.patch(insertTest_from,patch));
3535
}catch (PatchFailedExceptione) {
@@ -42,7 +42,7 @@ public void testPatch_Delete() {
4242
finalList<String>deleteTest_from =Arrays.asList("ddd","fff","ggg","hhh");
4343
finalList<String>deleteTest_to =Arrays.asList("ggg");
4444

45-
finalPatch<String>patch =DiffUtils.diff(deleteTest_from,deleteTest_to,newMeyersDiffWithLinearSpace<String>());
45+
finalPatch<String>patch =DiffUtils.diff(deleteTest_from,deleteTest_to,newMyersDiffWithLinearSpace<String>());
4646
try {
4747
assertEquals(deleteTest_to,DiffUtils.patch(deleteTest_from,patch));
4848
}catch (PatchFailedExceptione) {
@@ -55,7 +55,7 @@ public void testPatch_Change() {
5555
finalList<String>changeTest_from =Arrays.asList("aaa","bbb","ccc","ddd");
5656
finalList<String>changeTest_to =Arrays.asList("aaa","bxb","cxc","ddd");
5757

58-
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMeyersDiffWithLinearSpace<String>());
58+
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMyersDiffWithLinearSpace<String>());
5959
try {
6060
assertEquals(changeTest_to,DiffUtils.patch(changeTest_from,patch));
6161
}catch (PatchFailedExceptione) {
@@ -166,7 +166,7 @@ public void testPatch_Serializable() throws IOException, ClassNotFoundException
166166
finalList<String>changeTest_from =Arrays.asList("aaa","bbb","ccc","ddd");
167167
finalList<String>changeTest_to =Arrays.asList("aaa","bxb","cxc","ddd");
168168

169-
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMeyersDiffWithLinearSpace<String>());
169+
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMyersDiffWithLinearSpace<String>());
170170
ByteArrayOutputStreambaos =newByteArrayOutputStream();
171171
ObjectOutputStreamout =newObjectOutputStream(baos);
172172
out.writeObject(patch);
@@ -189,7 +189,7 @@ public void testPatch_Change_withExceptionProcessor() {
189189
finalList<String>changeTest_from =Arrays.asList("aaa","bbb","ccc","ddd");
190190
finalList<String>changeTest_to =Arrays.asList("aaa","bxb","cxc","ddd");
191191

192-
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMeyersDiffWithLinearSpace<String>());
192+
finalPatch<String>patch =DiffUtils.diff(changeTest_from,changeTest_to,newMyersDiffWithLinearSpace<String>());
193193

194194
changeTest_from.set(2,"CDC");
195195

‎java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithAllDiffAlgorithmsTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
importcom.github.difflib.DiffUtils;
1616
importcom.github.difflib.algorithm.DiffAlgorithmFactory;
17-
importcom.github.difflib.algorithm.myers.MeyersDiff;
18-
importcom.github.difflib.algorithm.myers.MeyersDiffWithLinearSpace;
17+
importcom.github.difflib.algorithm.myers.MyersDiff;
18+
importcom.github.difflib.algorithm.myers.MyersDiffWithLinearSpace;
1919
importjava.util.stream.Stream;
2020
importorg.junit.jupiter.api.AfterAll;
2121
importorg.junit.jupiter.params.ParameterizedTest;
@@ -25,14 +25,13 @@
2525
publicclassPatchWithAllDiffAlgorithmsTest {
2626

2727
privatestaticStream<Arguments>provideAlgorithms() {
28-
returnStream.of(
29-
Arguments.of(MeyersDiff.factory()),
30-
Arguments.of(MeyersDiffWithLinearSpace.factory()));
28+
returnStream.of(Arguments.of(MyersDiff.factory()),
29+
Arguments.of(MyersDiffWithLinearSpace.factory()));
3130
}
3231

3332
@AfterAll
3433
publicstaticvoidafterAll() {
35-
DiffUtils.withDefaultDiffAlgorithmFactory(MeyersDiff.factory());
34+
DiffUtils.withDefaultDiffAlgorithmFactory(MyersDiff.factory());
3635
}
3736

3837
@ParameterizedTest

‎java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithMeyerDiffTest.javarenamed to ‎java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithMyerDiffTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author tw
3030
*/
31-
publicclassPatchWithMeyerDiffTest {
31+
publicclassPatchWithMyerDiffTest {
3232

3333
@Test
3434
publicvoidtestPatch_Change_withExceptionProcessor() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp