Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Fix JavaDoc and some IntelliJ code inspection results #8

Merged
merged 1 commit into from
Jun 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java-diff-utils-lib/src/main/java/difflib/ChangeDelta.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> The type of the compared elements in the 'lines'.
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
*/
public class ChangeDelta<T> extends Delta<T> {
Expand Down
19 changes: 4 additions & 15 deletions java-diff-utils-lib/src/main/java/difflib/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <p> Text is represented as
* <code>Object[]</code> 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. </p>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
*/
public class Chunk<T> {
Expand Down Expand Up @@ -102,11 +103,6 @@ public int last() {
return getPosition() + size() - 1;
}

/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -117,11 +113,6 @@ public int hashCode() {
return result;
}

/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
Expand All @@ -136,9 +127,7 @@ public boolean equals(Object obj) {
return false;
} else if (!lines.equals(other.lines))
return false;
if (position != other.position)
return false;
return true;
return position == other.position;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java-diff-utils-lib/src/main/java/difflib/DeleteDelta.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Describes the delete-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
*/
public class DeleteDelta<T> extends Delta<T> {

Expand Down
13 changes: 6 additions & 7 deletions java-diff-utils-lib/src/main/java/difflib/Delta.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Describes the delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
*/
public abstract class Delta<T> {

Expand All @@ -35,7 +35,7 @@ public abstract class Delta<T> {
* Specifies the type of the delta.
*
*/
public static enum TYPE {
public enum TYPE {
/** A change in the original. */
CHANGE,
/** A delete from the original. */
Expand Down Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Delta<?>>, Serializable {
private static final long serialVersionUID = 1L;
Expand All @@ -24,4 +24,4 @@ public int compare(final Delta<?> a, final Delta<?> b) {
}
return 0;
}
}
}
8 changes: 4 additions & 4 deletions java-diff-utils-lib/src/main/java/difflib/DiffAlgorithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* The general interface for computing diffs between two lists of elements of type T.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
*/
public interface DiffAlgorithm<T> {

Expand All @@ -35,7 +35,7 @@ public interface DiffAlgorithm<T> {
* @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<T> diff(T[] original, T[] revised);
Patch<T> diff(T[] original, T[] revised);

/**
* Computes the difference between the original sequence and the revised
Expand All @@ -45,11 +45,11 @@ public interface DiffAlgorithm<T> {
* @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<T> diff(List<T> original, List<T> revised);
Patch<T> diff(List<T> original, List<T> revised);

/**
* Get equalizer use to compare data.
* @return
*/
public Equalizer<T> getEqualizer();
Equalizer<T> getEqualizer();
}
9 changes: 3 additions & 6 deletions java-diff-utils-lib/src/main/java/difflib/DiffRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public List<DiffRow> generateDiffRows(List<String> original, List<String> revise
return diffRows;
}

private static final void addChangeDiffRow(Equalizer<String> equalizer, List<DiffRow> diffRows, String orgLine,
private static void addChangeDiffRow(Equalizer<String> equalizer, List<DiffRow> diffRows, String orgLine,
String revLine, String defaultString) {
boolean skipOrg = equalizer.skip(orgLine);
boolean skipRev = equalizer.skip(revLine);
Expand Down Expand Up @@ -472,7 +472,7 @@ private List<String> addMissingLines(final List<String> lines, final int targetS
return tempList;
}

private static final LinkedList<String> charArrayToStringList(char[] cs) {
private static LinkedList<String> charArrayToStringList(char[] cs) {
LinkedList<String> result = new LinkedList<String>();
for (Character character : cs) {
result.add(character.toString());
Expand Down Expand Up @@ -559,4 +559,4 @@ public static String wrapInTag(String line, String tag, String cssClass) {

return startTag + PATTERN_CRLF.matcher(line).replaceAll(joinTag) + endTag;
}
}
}
3 changes: 1 addition & 2 deletions java-diff-utils-lib/src/main/java/difflib/DiffUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@

/**
* Implements the difference and patching engine
* @param T The type of the compared elements in the 'lines'.
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @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<String> readLines(@Nonnull File file) {
Expand Down
2 changes: 1 addition & 1 deletion java-diff-utils-lib/src/main/java/difflib/InsertDelta.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Describes the add-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param T
* @param <T>
* The type of the compared elements in the 'lines'.
*/
public class InsertDelta<T> extends Delta<T> {
Expand Down
2 changes: 1 addition & 1 deletion java-diff-utils-lib/src/main/java/difflib/Patch.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Describes the patch holding all deltas between the original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
*/
public class Patch<T> {
private List<Delta<T>> deltas = new LinkedList<Delta<T>>();
Expand Down
2 changes: 1 addition & 1 deletion java-diff-utils-lib/src/main/java/difflib/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions java-diff-utils-lib/src/main/java/difflib/myers/DiffNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> The type of the compared elements in the 'lines'.
*/
public interface Equalizer<T> {

Expand All @@ -17,13 +17,13 @@ public interface Equalizer<T> {
* @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.
* @param original
* @return
*/
@CheckReturnValue
public boolean skip(@Nullable T original);
boolean skip(@Nullable T original);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
* http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps</a></p>
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
* @param T The type of the compared elements in the 'lines'.
* @param <T> The type of the compared elements in the 'lines'.
*/
public class MyersDiff<T> implements DiffAlgorithm<T> {
/** Default equalizer. */
Expand Down Expand Up @@ -309,4 +309,4 @@ public static <T, U> T[] copyOfRange2(U[] original, int from, int to,
public Equalizer<T> getEqualizer() {
return equalizer;
}
}
}
4 changes: 2 additions & 2 deletions java-diff-utils-lib/src/main/java/difflib/myers/Snake.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down