sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1733046 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/referencing/IdentifiedObjects.java test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
Date Tue, 01 Mar 2016 12:11:59 GMT
Author: desruisseaux
Date: Tue Mar  1 12:11:59 2016
New Revision: 1733046

URL: http://svn.apache.org/viewvc?rev=1733046&view=rev
Log:
Test for null argument value.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1733046&r1=1733045&r2=1733046&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] Tue Mar  1 12:11:59 2016
@@ -552,19 +552,24 @@ public final class IdentifiedObjects ext
      *       projection or parameter name.</li>
      * </ul>
      *
-     * @param  object The object for which to check the name or alias.
+     * If the {@code object} argument is {@code null}, then this method returns {@code false}.
+     *
+     * @param  object The object for which to check the name or alias, or {@code null}.
      * @param  name The name to compare with the object name or aliases.
      * @return {@code true} if the primary name or at least one alias matches the specified
{@code name}.
      *
      * @see AbstractIdentifiedObject#isHeuristicMatchForName(String)
      */
     public static boolean isHeuristicMatchForName(final IdentifiedObject object, final String
name) {
+        ArgumentChecks.ensureNonNull("name", name);
+        if (object == null) {
+            return false;
+        }
         if (object instanceof AbstractIdentifiedObject) {
             // DefaultCoordinateSystemAxis overrides this method.
             // We really need to delegate to the overridden method.
             return ((AbstractIdentifiedObject) object).isHeuristicMatchForName(name);
         } else {
-            ArgumentChecks.ensureNonNull("object", object);
             return NameToIdentifier.isHeuristicMatchForName(object.getName(), object.getAlias(),
name,
                     NameToIdentifier.Simplifier.DEFAULT);
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java?rev=1733046&r1=1733045&r2=1733046&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
[UTF-8] Tue Mar  1 12:11:59 2016
@@ -59,6 +59,7 @@ public final strictfp class IdentifiedOb
         assertFalse(isHeuristicMatchForName(object, "testmyCode"));
         assertFalse(isHeuristicMatchForName(object, "other:myCode"));
         assertFalse(isHeuristicMatchForName(object, "test"));
+        assertFalse(isHeuristicMatchForName(null,   "myCode"));
 
         // Test the alias.
         assertTrue (isHeuristicMatchForName(object, "myName"));



Mime
View raw message