You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/06/09 16:48:56 UTC

[11/50] [abbrv] [text] Similarity package: do not mention Strings in IllegalArgumentException messages and java doc when parameters are CharSequences

Similarity package: do not mention Strings in IllegalArgumentException messages and java doc when parameters are CharSequences


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/ea1765e0
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/ea1765e0
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/ea1765e0

Branch: refs/heads/release
Commit: ea1765e01ed3b269572b8ca6f1743c6b5ac71b37
Parents: 26a308f
Author: Pascal Schumacher <pa...@gmx.net>
Authored: Wed Apr 4 17:17:07 2018 +0200
Committer: Pascal Schumacher <pa...@gmx.net>
Committed: Wed Apr 4 17:17:07 2018 +0200

----------------------------------------------------------------------
 .../commons/text/similarity/HammingDistance.java      |  4 ++--
 .../commons/text/similarity/JaroWinklerDistance.java  |  8 ++++----
 .../text/similarity/LevenshteinDetailedDistance.java  | 14 +++++++-------
 .../commons/text/similarity/LevenshteinDistance.java  |  6 +++---
 4 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/ea1765e0/src/main/java/org/apache/commons/text/similarity/HammingDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/HammingDistance.java b/src/main/java/org/apache/commons/text/similarity/HammingDistance.java
index 8d88fe8..183fbd9 100644
--- a/src/main/java/org/apache/commons/text/similarity/HammingDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/HammingDistance.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/commons-text/blob/ea1765e0/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
index 8146eaf..0ffb1ad 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/commons-text/blob/ea1765e0/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
index 00b2689..6e92cb6 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
@@ -150,8 +150,8 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * 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
      */
@@ -159,7 +159,7 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                                                      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");
@@ -331,14 +331,14 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * 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");
         }
 
         /*

http://git-wip-us.apache.org/repos/asf/commons-text/blob/ea1765e0/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
index a8fab04..1b1e903 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
@@ -158,14 +158,14 @@ public class LevenshteinDistance implements EditDistance<Integer> {
      * 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");