Skip to content

Commit

Permalink
Similarity package: do not mention Strings in IllegalArgumentExceptio…
Browse files Browse the repository at this point in the history
…n messages and java doc when parameters are CharSequences
  • Loading branch information
PascalSchumacher committed Apr 4, 2018
1 parent 26a308f commit ea1765e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public class HammingDistance implements EditDistance<Integer> {
@Override
public Integer apply(final CharSequence left, final CharSequence right) {
if (left == null || right == null) {
throw new IllegalArgumentException("Strings must not be null");
throw new IllegalArgumentException("CharSequences must not be null");
}

if (left.length() != right.length()) {
throw new IllegalArgumentException("Strings must have the same length");
throw new IllegalArgumentException("CharSequences must have the same length");
}

int distance = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ public class JaroWinklerDistance implements SimilarityScore<Double> {
* distance.apply("PENNSYLVANIA", "PENNCISYLVNIA") = 0.88
* </pre>
*
* @param left the first String, must not be null
* @param right the second String, must not be null
* @param left the first CharSequence, must not be null
* @param right the second CharSequence, must not be null
* @return result distance
* @throws IllegalArgumentException if either String input {@code null}
* @throws IllegalArgumentException if either CharSequence input is {@code null}
*/
@Override
public Double apply(final CharSequence left, final CharSequence right) {
final double defaultScalingFactor = 0.1;

if (left == null || right == null) {
throw new IllegalArgumentException("Strings must not be null");
throw new IllegalArgumentException("CharSequences must not be null");
}

final int[] mtp = matches(left, right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ public Integer getThreshold() {
* limitedCompare("hippo", "elephant", 6) = -1
* </pre>
*
* @param left the first string, must not be null
* @param right the second string, must not be null
* @param left the first CharSequence, must not be null
* @param right the second CharSequence, must not be null
* @param threshold the target threshold, must not be negative
* @return result distance, or -1
*/
private static LevenshteinResults limitedCompare(CharSequence left,
CharSequence right,
final int threshold) { //NOPMD
if (left == null || right == null) {
throw new IllegalArgumentException("Strings must not be null");
throw new IllegalArgumentException("CharSequences must not be null");
}
if (threshold < 0) {
throw new IllegalArgumentException("Threshold must not be negative");
Expand Down Expand Up @@ -331,14 +331,14 @@ private static LevenshteinResults limitedCompare(CharSequence left,
* unlimitedCompare("hello", "hallo") = 1
* </pre>
*
* @param left the first String, must not be null
* @param right the second String, must not be null
* @param left the first CharSequence, must not be null
* @param right the second CharSequence, must not be null
* @return result distance, or -1
* @throws IllegalArgumentException if either String input {@code null}
* @throws IllegalArgumentException if either CharSequence input is {@code null}
*/
private static LevenshteinResults unlimitedCompare(CharSequence left, CharSequence right) {
if (left == null || right == null) {
throw new IllegalArgumentException("Strings must not be null");
throw new IllegalArgumentException("CharSequences must not be null");
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ public Integer getThreshold() {
* limitedCompare("hippo", "elephant", 6) = -1
* </pre>
*
* @param left the first string, must not be null
* @param right the second string, must not be null
* @param left the first CharSequence, must not be null
* @param right the second CharSequence, must not be null
* @param threshold the target threshold, must not be negative
* @return result distance, or -1
*/
private static int limitedCompare(CharSequence left, CharSequence right, final int threshold) { // NOPMD
if (left == null || right == null) {
throw new IllegalArgumentException("Strings must not be null");
throw new IllegalArgumentException("CharSequences must not be null");
}
if (threshold < 0) {
throw new IllegalArgumentException("Threshold must not be negative");
Expand Down

0 comments on commit ea1765e

Please sign in to comment.