Skip to content

Commit 2787a2d

Browse files
authored
Merge pull request java-diff-utils#30 from skitt/cleanups
Cleanups
2 parents 5dd05c4 + e8c015a commit 2787a2d

File tree

15 files changed

+28
-42
lines changed

15 files changed

+28
-42
lines changed

src/main/java/com/github/difflib/DiffUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.List;
2929
import java.util.Objects;
3030
import java.util.function.BiPredicate;
31-
import static java.util.stream.Collectors.joining;
3231

3332
/**
3433
* Implements the difference and patching engine
@@ -143,7 +142,7 @@ private static List<String> compressLines(List<String> lines, String delimiter)
143142
if (lines.isEmpty()) {
144143
return Collections.emptyList();
145144
}
146-
return Collections.singletonList(lines.stream().collect(joining(delimiter)));
145+
return Collections.singletonList(String.join(delimiter, lines));
147146
}
148147

149148
/**

src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
/**
1919
* Thrown whenever the differencing engine cannot produce the differences between two revisions of ta text.
2020
*
21-
* @see MyersDiff
22-
* @see difflib.DiffAlgorithm
21+
* @see com.github.difflib.algorithm.myers.MyersDiff
22+
* @see DiffAlgorithmI
2323
*/
2424
public class DifferentiationFailedException extends DiffException {
2525

src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.github.difflib.algorithm.Change;
1919
import com.github.difflib.algorithm.DiffAlgorithmI;
2020
import com.github.difflib.algorithm.DiffAlgorithmListener;
21-
import com.github.difflib.algorithm.DiffException;
2221
import com.github.difflib.patch.DeltaType;
2322
import java.util.ArrayList;
2423
import java.util.List;
@@ -37,7 +36,7 @@
3736
public class HistogramDiff<T> implements DiffAlgorithmI<T> {
3837

3938
@Override
40-
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) throws DiffException {
39+
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) {
4140
Objects.requireNonNull(source, "source list must not be null");
4241
Objects.requireNonNull(target, "target list must not be null");
4342
if (progress != null) {

src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private PathNode buildPath(final List<T> orig, final List<T> rev, DiffAlgorithmL
138138
/**
139139
* Constructs a {@link Patch} from a difference path.
140140
*
141-
* @param path The path.
141+
* @param actualPath The path.
142142
* @param orig The original sequence.
143143
* @param rev The revised sequence.
144144
* @return A {@link Patch} script corresponding to the path.

src/main/java/com/github/difflib/algorithm/myers/PathNode.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
* A node in a diffpath.
2020
*
2121
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
22-
*
23-
* @see DiffNode
24-
* @see Snake
25-
*
2622
*/
2723
public final class PathNode {
2824

@@ -78,10 +74,10 @@ public boolean isBootstrap() {
7874
}
7975

8076
/**
81-
* Skips sequences of {@link DiffNode DiffNodes} until a {@link Snake} or bootstrap node is found, or the end of the
77+
* Skips sequences of {@link PathNode PathNodes} until a snake or bootstrap node is found, or the end of the
8278
* path is reached.
8379
*
84-
* @return The next first {@link Snake} or bootstrap node in the path, or <code>null</code> if none found.
80+
* @return The next first {@link PathNode} or bootstrap node in the path, or <code>null</code> if none found.
8581
*/
8682
public final PathNode previousSnake() {
8783
if (isBootstrap()) {
@@ -102,9 +98,9 @@ public String toString() {
10298
PathNode node = this;
10399
while (node != null) {
104100
buf.append("(");
105-
buf.append(Integer.toString(node.i));
101+
buf.append(node.i);
106102
buf.append(",");
107-
buf.append(Integer.toString(node.j));
103+
buf.append(node.j);
108104
buf.append(")");
109105
node = node.prev;
110106
}

src/main/java/com/github/difflib/patch/ChangeDelta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Describes the change-delta between original and revised texts.
2323
*
2424
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
25-
* @param T The type of the compared elements in the data 'lines'.
25+
* @param <T> The type of the compared elements in the data 'lines'.
2626
*/
2727
public final class ChangeDelta<T> extends AbstractDelta<T> {
2828

src/main/java/com/github/difflib/patch/Chunk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* </p>
3030
*
3131
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
32-
* @param T The type of the compared elements in the 'lines'.
32+
* @param <T> The type of the compared elements in the 'lines'.
3333
*/
3434
public final class Chunk<T> {
3535

src/main/java/com/github/difflib/patch/DeleteDelta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Describes the delete-delta between original and revised texts.
2222
*
2323
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
24-
* @param T The type of the compared elements in the 'lines'.
24+
* @param <T> The type of the compared elements in the 'lines'.
2525
*/
2626
public final class DeleteDelta<T> extends AbstractDelta<T> {
2727

src/main/java/com/github/difflib/patch/InsertDelta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Describes the add-delta between original and revised texts.
2222
*
2323
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
24-
* @param T The type of the compared elements in the 'lines'.
24+
* @param <T> The type of the compared elements in the 'lines'.
2525
*/
2626
public final class InsertDelta<T> extends AbstractDelta<T> {
2727

src/main/java/com/github/difflib/patch/Patch.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@
1919
*/
2020
package com.github.difflib.patch;
2121

22+
import static java.util.Comparator.comparing;
2223
import com.github.difflib.algorithm.Change;
23-
import static com.github.difflib.patch.DeltaType.DELETE;
24-
import static com.github.difflib.patch.DeltaType.INSERT;
2524
import java.util.ArrayList;
26-
import java.util.Collections;
27-
import static java.util.Comparator.comparing;
2825
import java.util.List;
2926
import java.util.ListIterator;
3027

3128
/**
3229
* Describes the patch holding all deltas between the original and revised texts.
3330
*
3431
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
35-
* @param T The type of the compared elements in the 'lines'.
32+
* @param <T> The type of the compared elements in the 'lines'.
3633
*/
3734
public final class Patch<T> {
3835

@@ -93,7 +90,7 @@ public void addDelta(AbstractDelta<T> delta) {
9390
* @return the deltas
9491
*/
9592
public List<AbstractDelta<T>> getDeltas() {
96-
Collections.sort(deltas, comparing(d -> d.getSource().getPosition()));
93+
deltas.sort(comparing(d -> d.getSource().getPosition()));
9794
return deltas;
9895
}
9996

0 commit comments

Comments
 (0)