You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2018/04/04 15:17:26 UTC

[1/2] [text] DateStringLookup: remove confusing part of IllegalArgumentException message

Repository: commons-text
Updated Branches:
  refs/heads/master 8dde83f91 -> ea1765e01


DateStringLookup: remove confusing part of IllegalArgumentException message


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

Branch: refs/heads/master
Commit: 26a308f40f9026fb1f5cffb0f359270a5a3b345c
Parents: 8dde83f
Author: Pascal Schumacher <pa...@gmx.net>
Authored: Wed Apr 4 17:04:35 2018 +0200
Committer: Pascal Schumacher <pa...@gmx.net>
Committed: Wed Apr 4 17:04:35 2018 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/text/lookup/DateStringLookup.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/26a308f4/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java b/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java
index cb4908a..e7f0114 100644
--- a/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/DateStringLookup.java
@@ -55,7 +55,7 @@ final class DateStringLookup extends AbstractStringLookup {
             try {
                 dateFormat = FastDateFormat.getInstance(format);
             } catch (final Exception ex) {
-                throw IllegalArgumentExceptions.format(ex, "Invalid date format: [%s], using default", format);
+                throw IllegalArgumentExceptions.format(ex, "Invalid date format: [%s]", format);
             }
         }
         if (dateFormat == null) {


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

Posted by pa...@apache.org.
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/master
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");