diff --git a/java-diff-utils-jgit/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java b/java-diff-utils-jgit/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java index 0476b26..a171505 100644 --- a/java-diff-utils-jgit/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java +++ b/java-diff-utils-jgit/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java @@ -36,7 +36,8 @@ public class HistogramDiff implements DiffAlgorithmI { @Override - public List computeDiff(List source, List target, DiffAlgorithmListener progress) { + public List computeDiff( + List source, List target, DiffAlgorithmListener progress) { Objects.requireNonNull(source, "source list must not be null"); Objects.requireNonNull(target, "target list must not be null"); if (progress != null) { @@ -92,9 +93,9 @@ public int hash(DataList s, int i) { class DataList extends Sequence { - final List data; + final List data; - public DataList(List data) { + public DataList(List data) { this.data = data; } diff --git a/java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java b/java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java index e43be50..8448a76 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java +++ b/java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java @@ -57,7 +57,8 @@ public static void withDefaultDiffAlgorithmFactory(DiffAlgorithmFactory factory) * @param progress a {@link DiffAlgorithmListener} representing the progress listener. Can be {@code null}. * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ - public static Patch diff(List original, List revised, DiffAlgorithmListener progress) { + public static Patch diff( + List original, List revised, DiffAlgorithmListener progress) { return DiffUtils.diff(original, revised, DEFAULT_DIFF.create(), progress); } @@ -69,7 +70,7 @@ public static Patch diff(List original, List revised, DiffAlgorithm * @param revised a {@link List} representing the revised sequence of elements. Must not be {@code null}. * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ - public static Patch diff(List original, List revised) { + public static Patch diff(List original, List revised) { return DiffUtils.diff(original, revised, DEFAULT_DIFF.create(), null); } @@ -82,7 +83,7 @@ public static Patch diff(List original, List revised) { * @param includeEqualParts a {@link boolean} representing whether to include equal parts in the resulting patch. * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ - public static Patch diff(List original, List revised, boolean includeEqualParts) { + public static Patch diff(List original, List revised, boolean includeEqualParts) { return DiffUtils.diff(original, revised, DEFAULT_DIFF.create(), null, includeEqualParts); } @@ -110,7 +111,8 @@ public static Patch diff(String sourceText, String targetText, DiffAlgor * @return The patch describing the difference between the original and * revised sequences. Never {@code null}. */ - public static Patch diff(List source, List target, BiPredicate equalizer) { + public static Patch diff( + List source, List target, BiPredicate equalizer) { if (equalizer != null) { return DiffUtils.diff(source, target, DEFAULT_DIFF.create(equalizer)); } @@ -118,7 +120,10 @@ public static Patch diff(List source, List target, BiPredicate Patch diff( - List original, List revised, DiffAlgorithmI algorithm, DiffAlgorithmListener progress) { + List original, + List revised, + DiffAlgorithmI algorithm, + DiffAlgorithmListener progress) { return diff(original, revised, algorithm, progress, false); } @@ -135,8 +140,8 @@ public static Patch diff( * revised sequences. Never {@code null}. */ public static Patch diff( - List original, - List revised, + List original, + List revised, DiffAlgorithmI algorithm, DiffAlgorithmListener progress, boolean includeEqualParts) { @@ -157,7 +162,8 @@ public static Patch diff( * @return The patch describing the difference between the original and * revised sequences. Never {@code null}. */ - public static Patch diff(List original, List revised, DiffAlgorithmI algorithm) { + public static Patch diff( + List original, List revised, DiffAlgorithmI algorithm) { return diff(original, revised, algorithm, null); } @@ -196,7 +202,7 @@ public static Patch diffInline(String original, String revised) { * @return the revised list. * @throws PatchFailedException if the patch cannot be applied. */ - public static List patch(List original, Patch patch) throws PatchFailedException { + public static List patch(List original, Patch patch) throws PatchFailedException { return patch.applyTo(original); } @@ -208,7 +214,7 @@ public static List patch(List original, Patch patch) throws PatchFa * @return the original list. * @throws PatchFailedException if the patch cannot be applied. */ - public static List unpatch(List revised, Patch patch) { + public static List unpatch(List revised, Patch patch) { return patch.restore(revised); } diff --git a/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmFactory.java b/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmFactory.java index 307ee7e..5b9d71c 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmFactory.java +++ b/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmFactory.java @@ -25,5 +25,5 @@ public interface DiffAlgorithmFactory { DiffAlgorithmI create(); - DiffAlgorithmI create(BiPredicate equalizer); + DiffAlgorithmI create(BiPredicate equalizer); } diff --git a/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java b/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java index a12b499..ee421c5 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java +++ b/java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java @@ -34,7 +34,7 @@ public interface DiffAlgorithmI { * @param progress progress listener * @return */ - List computeDiff(List source, List target, DiffAlgorithmListener progress); + List computeDiff(List source, List target, DiffAlgorithmListener progress); /** * Simple extension to compute a changeset using arrays. diff --git a/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java b/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java index 5233e02..c990208 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java +++ b/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java @@ -31,13 +31,13 @@ */ public final class MyersDiff implements DiffAlgorithmI { - private final BiPredicate equalizer; + private final BiPredicate equalizer; public MyersDiff() { equalizer = Object::equals; } - public MyersDiff(final BiPredicate equalizer) { + public MyersDiff(final BiPredicate equalizer) { Objects.requireNonNull(equalizer, "equalizer must not be null"); this.equalizer = equalizer; } @@ -48,7 +48,8 @@ public MyersDiff(final BiPredicate equalizer) { * Return empty diff if get the error while procession the difference. */ @Override - public List computeDiff(final List source, final List target, DiffAlgorithmListener progress) { + public List computeDiff( + final List source, final List target, DiffAlgorithmListener progress) { Objects.requireNonNull(source, "source list must not be null"); Objects.requireNonNull(target, "target list must not be null"); @@ -71,9 +72,10 @@ public List computeDiff(final List source, final List target, Diff * @param orig The original sequence. * @param rev The revised sequence. * @return A minimum {@link PathNode Path} accross the differences graph. - * @throws DifferentiationFailedException if a diff path could not be found. + * @throws IllegalStateException if a diff path could not be found. */ - private PathNode buildPath(final List orig, final List rev, DiffAlgorithmListener progress) { + private PathNode buildPath( + final List orig, final List rev, DiffAlgorithmListener progress) { Objects.requireNonNull(orig, "original sequence is null"); Objects.requireNonNull(rev, "revised sequence is null"); @@ -140,10 +142,10 @@ private PathNode buildPath(final List orig, final List rev, DiffAlgorithmL * @param orig The original sequence. * @param rev The revised sequence. * @return A {@link Patch} script corresponding to the path. - * @throws DifferentiationFailedException if a {@link Patch} could not be + * @throws IllegalStateException if a {@link Patch} could not be * built from the given path. */ - private List buildRevision(PathNode actualPath, List orig, List rev) { + private List buildRevision(PathNode actualPath, List orig, List rev) { Objects.requireNonNull(actualPath, "path is null"); Objects.requireNonNull(orig, "original sequence is null"); Objects.requireNonNull(rev, "revised sequence is null"); @@ -190,7 +192,7 @@ public DiffAlgorithmI create() { } @Override - public DiffAlgorithmI create(BiPredicate equalizer) { + public DiffAlgorithmI create(BiPredicate equalizer) { return new MyersDiff<>(equalizer); } }; diff --git a/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java b/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java index f8c734b..2e1a53c 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java +++ b/java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java @@ -32,19 +32,20 @@ */ public class MyersDiffWithLinearSpace implements DiffAlgorithmI { - private final BiPredicate equalizer; + private final BiPredicate equalizer; public MyersDiffWithLinearSpace() { equalizer = Object::equals; } - public MyersDiffWithLinearSpace(final BiPredicate equalizer) { + public MyersDiffWithLinearSpace(final BiPredicate equalizer) { Objects.requireNonNull(equalizer, "equalizer must not be null"); this.equalizer = equalizer; } @Override - public List computeDiff(List source, List target, DiffAlgorithmListener progress) { + public List computeDiff( + List source, List target, DiffAlgorithmListener progress) { Objects.requireNonNull(source, "source list must not be null"); Objects.requireNonNull(target, "target list must not be null"); @@ -200,10 +201,10 @@ private class DiffData { final int[] vDown; final int[] vUp; final List script; - final List source; - final List target; + final List source; + final List target; - public DiffData(List source, List target) { + public DiffData(List source, List target) { this.source = source; this.target = target; size = source.size() + target.size() + 2; @@ -237,7 +238,7 @@ public DiffAlgorithmI create() { } @Override - public DiffAlgorithmI create(BiPredicate equalizer) { + public DiffAlgorithmI create(BiPredicate equalizer) { return new MyersDiffWithLinearSpace<>(equalizer); } }; diff --git a/java-diff-utils/src/main/java/com/github/difflib/patch/EqualDelta.java b/java-diff-utils/src/main/java/com/github/difflib/patch/EqualDelta.java index 64f0568..98cb561 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/patch/EqualDelta.java +++ b/java-diff-utils/src/main/java/com/github/difflib/patch/EqualDelta.java @@ -18,7 +18,7 @@ import java.util.List; /** - * This delta contains equal lines of data. Therefore nothing is to do in applyTo and restore. + * This delta contains equal lines of data. Therefore, nothing is to do in applyTo and restore. * @author tobens */ public class EqualDelta extends AbstractDelta { @@ -49,6 +49,6 @@ public String toString() { @Override public AbstractDelta withChunks(Chunk original, Chunk revised) { - return new EqualDelta(original, revised); + return new EqualDelta<>(original, revised); } } diff --git a/java-diff-utils/src/main/java/com/github/difflib/patch/Patch.java b/java-diff-utils/src/main/java/com/github/difflib/patch/Patch.java index 6a54d82..31c2c3e 100644 --- a/java-diff-utils/src/main/java/com/github/difflib/patch/Patch.java +++ b/java-diff-utils/src/main/java/com/github/difflib/patch/Patch.java @@ -54,7 +54,7 @@ public Patch(int estimatedPatchSize) { * @return A new list containing the applied patch. * @throws PatchFailedException if the patch cannot be applied */ - public List applyTo(List target) throws PatchFailedException { + public List applyTo(List target) throws PatchFailedException { List result = new ArrayList<>(target); applyToExisting(result); return result; @@ -244,7 +244,7 @@ public Patch withConflictOutput(ConflictOutput conflictOutput) { * @param target The list to copy and apply changes to. * @return A new list, containing the restored state. */ - public List restore(List target) { + public List restore(List target) { List result = new ArrayList<>(target); restoreToExisting(result); return result; @@ -294,12 +294,12 @@ public static Patch generate(List original, List revised, List Chunk buildChunk(int start, int end, List data) { + private static Chunk buildChunk(int start, int end, List data) { return new Chunk<>(start, new ArrayList<>(data.subList(start, end))); } public static Patch generate( - List original, List revised, List _changes, boolean includeEquals) { + List original, List revised, List _changes, boolean includeEquals) { Patch patch = new Patch<>(_changes.size()); int startOriginal = 0; int startRevised = 0; diff --git a/pom.xml b/pom.xml index e39a81d..d0d5b28 100644 --- a/pom.xml +++ b/pom.xml @@ -132,28 +132,28 @@ ${project.build.sourceDirectory} - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - + + + + - + @@ -188,10 +188,10 @@ com.diffplug.spotless spotless-maven-plugin - 2.30.0 + 2.46.0 - + true 2