diff --git a/java-diff-utils-lib/src/main/java/difflib/ChangeDelta.java b/java-diff-utils-lib/src/main/java/difflib/ChangeDelta.java index 95252d9..06f8b9e 100644 --- a/java-diff-utils-lib/src/main/java/difflib/ChangeDelta.java +++ b/java-diff-utils-lib/src/main/java/difflib/ChangeDelta.java @@ -19,7 +19,7 @@ /** * Describes the change-delta between original and revised texts. - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. * @author Dmitry Naumenko */ public class ChangeDelta extends Delta { diff --git a/java-diff-utils-lib/src/main/java/difflib/Chunk.java b/java-diff-utils-lib/src/main/java/difflib/Chunk.java index d1bf25e..871aaba 100644 --- a/java-diff-utils-lib/src/main/java/difflib/Chunk.java +++ b/java-diff-utils-lib/src/main/java/difflib/Chunk.java @@ -15,16 +15,17 @@ */ package difflib; -import javax.annotation.Nonnegative; import java.util.Arrays; import java.util.List; +import javax.annotation.Nonnegative; + /** * Holds the information about the part of text involved in the diff process

Text is represented as * Object[] because the diff engine is capable of handling more than plain ascci. In fact, arrays or lists * of any type that implements {@link java.lang.Object#hashCode hashCode()} and {@link java.lang.Object#equals equals()} * correctly can be subject to differencing using this library.

- * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class DeleteDelta extends Delta { diff --git a/java-diff-utils-lib/src/main/java/difflib/Delta.java b/java-diff-utils-lib/src/main/java/difflib/Delta.java index f2c805d..c680fd7 100644 --- a/java-diff-utils-lib/src/main/java/difflib/Delta.java +++ b/java-diff-utils-lib/src/main/java/difflib/Delta.java @@ -21,7 +21,7 @@ * Describes the delta between original and revised texts. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public abstract class Delta { @@ -35,7 +35,7 @@ public abstract class Delta { * Specifies the type of the delta. * */ - public static enum TYPE { + public enum TYPE { /** A change in the original. */ CHANGE, /** A delete from the original. */ @@ -143,11 +143,10 @@ public boolean equals(Object obj) { } else if (!original.equals(other.original)) return false; if (revised == null) { - if (other.revised != null) - return false; - } else if (!revised.equals(other.revised)) - return false; - return true; + return other.revised == null; + } else { + return revised.equals(other.revised); + } } } diff --git a/java-diff-utils-lib/src/main/java/difflib/DeltaComparator.java b/java-diff-utils-lib/src/main/java/difflib/DeltaComparator.java index 98b7ab3..ff12412 100644 --- a/java-diff-utils-lib/src/main/java/difflib/DeltaComparator.java +++ b/java-diff-utils-lib/src/main/java/difflib/DeltaComparator.java @@ -5,7 +5,7 @@ /** * @author mksenzov - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class DeltaComparator implements Comparator>, Serializable { private static final long serialVersionUID = 1L; @@ -24,4 +24,4 @@ public int compare(final Delta a, final Delta b) { } return 0; } -} \ No newline at end of file +} diff --git a/java-diff-utils-lib/src/main/java/difflib/DiffAlgorithm.java b/java-diff-utils-lib/src/main/java/difflib/DiffAlgorithm.java index 5a2ddea..0d6518f 100644 --- a/java-diff-utils-lib/src/main/java/difflib/DiffAlgorithm.java +++ b/java-diff-utils-lib/src/main/java/difflib/DiffAlgorithm.java @@ -23,7 +23,7 @@ * The general interface for computing diffs between two lists of elements of type T. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public interface DiffAlgorithm { @@ -35,7 +35,7 @@ public interface DiffAlgorithm { * @param revised The revised sequence. Must not be {@code null}. * @return The patch representing the diff of the given sequences. Never {@code null}. */ - public Patch diff(T[] original, T[] revised); + Patch diff(T[] original, T[] revised); /** * Computes the difference between the original sequence and the revised @@ -45,11 +45,11 @@ public interface DiffAlgorithm { * @param revised The revised sequence. Must not be {@code null}. * @return The patch representing the diff of the given sequences. Never {@code null}. */ - public Patch diff(List original, List revised); + Patch diff(List original, List revised); /** * Get equalizer use to compare data. * @return */ - public Equalizer getEqualizer(); + Equalizer getEqualizer(); } diff --git a/java-diff-utils-lib/src/main/java/difflib/DiffRow.java b/java-diff-utils-lib/src/main/java/difflib/DiffRow.java index 95f08bc..08c5450 100644 --- a/java-diff-utils-lib/src/main/java/difflib/DiffRow.java +++ b/java-diff-utils-lib/src/main/java/difflib/DiffRow.java @@ -36,7 +36,7 @@ public DiffRow(@Nonnull Tag tag, @Nullable String oldLine, @Nullable String newL this.newLine = newLine; } - public static enum Tag { + public enum Tag { INSERT, DELETE, CHANGE, EQUAL, SKIP } @@ -125,11 +125,8 @@ public boolean equals(Object obj) { } else if (!oldLine.equals(other.oldLine)) return false; if (tag == null) { - if (other.tag != null) - return false; - } else if (!tag.equals(other.tag)) - return false; - return true; + return other.tag == null; + } else return tag.equals(other.tag); } public String toString() { diff --git a/java-diff-utils-lib/src/main/java/difflib/DiffRowGenerator.java b/java-diff-utils-lib/src/main/java/difflib/DiffRowGenerator.java index 8d37612..9f3ac7b 100644 --- a/java-diff-utils-lib/src/main/java/difflib/DiffRowGenerator.java +++ b/java-diff-utils-lib/src/main/java/difflib/DiffRowGenerator.java @@ -388,7 +388,7 @@ public List generateDiffRows(List original, List revise return diffRows; } - private static final void addChangeDiffRow(Equalizer equalizer, List diffRows, String orgLine, + private static void addChangeDiffRow(Equalizer equalizer, List diffRows, String orgLine, String revLine, String defaultString) { boolean skipOrg = equalizer.skip(orgLine); boolean skipRev = equalizer.skip(revLine); @@ -472,7 +472,7 @@ private List addMissingLines(final List lines, final int targetS return tempList; } - private static final LinkedList charArrayToStringList(char[] cs) { + private static LinkedList charArrayToStringList(char[] cs) { LinkedList result = new LinkedList(); for (Character character : cs) { result.add(character.toString()); @@ -559,4 +559,4 @@ public static String wrapInTag(String line, String tag, String cssClass) { return startTag + PATTERN_CRLF.matcher(line).replaceAll(joinTag) + endTag; } -} \ No newline at end of file +} diff --git a/java-diff-utils-lib/src/main/java/difflib/DiffUtils.java b/java-diff-utils-lib/src/main/java/difflib/DiffUtils.java index 505b0be..2de9068 100644 --- a/java-diff-utils-lib/src/main/java/difflib/DiffUtils.java +++ b/java-diff-utils-lib/src/main/java/difflib/DiffUtils.java @@ -28,13 +28,12 @@ /** * Implements the difference and patching engine - * @param T The type of the compared elements in the 'lines'. * @author Dmitry Naumenko * @version 0.4.1 */ public class DiffUtils { - private static Pattern unifiedDiffChunkRe = Pattern + private static final Pattern unifiedDiffChunkRe = Pattern .compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$"); private List readLines(@Nonnull File file) { diff --git a/java-diff-utils-lib/src/main/java/difflib/InsertDelta.java b/java-diff-utils-lib/src/main/java/difflib/InsertDelta.java index 23914a9..fb5b725 100644 --- a/java-diff-utils-lib/src/main/java/difflib/InsertDelta.java +++ b/java-diff-utils-lib/src/main/java/difflib/InsertDelta.java @@ -21,7 +21,7 @@ * Describes the add-delta between original and revised texts. * * @author Dmitry Naumenko - * @param T + * @param * The type of the compared elements in the 'lines'. */ public class InsertDelta extends Delta { diff --git a/java-diff-utils-lib/src/main/java/difflib/Patch.java b/java-diff-utils-lib/src/main/java/difflib/Patch.java index b93a5f1..36e4c18 100644 --- a/java-diff-utils-lib/src/main/java/difflib/Patch.java +++ b/java-diff-utils-lib/src/main/java/difflib/Patch.java @@ -24,7 +24,7 @@ * Describes the patch holding all deltas between the original and revised texts. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class Patch { private List> deltas = new LinkedList>(); diff --git a/java-diff-utils-lib/src/main/java/difflib/Utils.java b/java-diff-utils-lib/src/main/java/difflib/Utils.java index 7607e1a..731ab51 100644 --- a/java-diff-utils-lib/src/main/java/difflib/Utils.java +++ b/java-diff-utils-lib/src/main/java/difflib/Utils.java @@ -21,7 +21,7 @@ import java.util.List; public class Utils { - public static Charset UTF_8 = Charset.forName("UTF-8"); + public static final Charset UTF_8 = Charset.forName("UTF-8"); /** * Replaces all tabs with 4 spaces. diff --git a/java-diff-utils-lib/src/main/java/difflib/myers/DiffNode.java b/java-diff-utils-lib/src/main/java/difflib/myers/DiffNode.java index 64f0674..ff35b64 100644 --- a/java-diff-utils-lib/src/main/java/difflib/myers/DiffNode.java +++ b/java-diff-utils-lib/src/main/java/difflib/myers/DiffNode.java @@ -24,8 +24,8 @@ public final class DiffNode extends PathNode { * will be followed using {@link PathNode#previousSnake} * until a non-diff node is found. * - * @param the position in the original sequence - * @param the position in the revised sequence + * @param i position in the original sequence + * @param j position in the revised sequence * @param prev the previous node in the path. */ public DiffNode(int i, int j, PathNode prev) { diff --git a/java-diff-utils-lib/src/main/java/difflib/myers/Equalizer.java b/java-diff-utils-lib/src/main/java/difflib/myers/Equalizer.java index 4202ca3..b28da14 100644 --- a/java-diff-utils-lib/src/main/java/difflib/myers/Equalizer.java +++ b/java-diff-utils-lib/src/main/java/difflib/myers/Equalizer.java @@ -6,7 +6,7 @@ /** * Specifies when two compared elements in the Myers algorithm are equal. * - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public interface Equalizer { @@ -17,7 +17,7 @@ public interface Equalizer { * @return Returns true if the elements are equal. */ @CheckReturnValue - public boolean equals(@Nullable T original, @Nullable T revised); + boolean equals(@Nullable T original, @Nullable T revised); /** * Indicates if elements must be skipped. @@ -25,5 +25,5 @@ public interface Equalizer { * @return */ @CheckReturnValue - public boolean skip(@Nullable T original); + boolean skip(@Nullable T original); } diff --git a/java-diff-utils-lib/src/main/java/difflib/myers/MyersDiff.java b/java-diff-utils-lib/src/main/java/difflib/myers/MyersDiff.java index 9cccc85..47f8b89 100644 --- a/java-diff-utils-lib/src/main/java/difflib/myers/MyersDiff.java +++ b/java-diff-utils-lib/src/main/java/difflib/myers/MyersDiff.java @@ -72,7 +72,7 @@ * http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps

* * @author Juanco Anez - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class MyersDiff implements DiffAlgorithm { /** Default equalizer. */ @@ -309,4 +309,4 @@ public static T[] copyOfRange2(U[] original, int from, int to, public Equalizer getEqualizer() { return equalizer; } -} \ No newline at end of file +} diff --git a/java-diff-utils-lib/src/main/java/difflib/myers/Snake.java b/java-diff-utils-lib/src/main/java/difflib/myers/Snake.java index 09dc7d9..e04fe75 100644 --- a/java-diff-utils-lib/src/main/java/difflib/myers/Snake.java +++ b/java-diff-utils-lib/src/main/java/difflib/myers/Snake.java @@ -73,8 +73,8 @@ public final class Snake extends PathNode { /** * Constructs a snake node. * - * @param the position in the original sequence - * @param the position in the revised sequence + * @param i position in the original sequence + * @param j position in the revised sequence * @param prev the previous node in the path. */ public Snake(int i, int j, PathNode prev) {