sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1594155 - in /sis/branches/JDK8/core/sis-feature/src: main/java/org/apache/sis/feature/ test/java/org/apache/sis/feature/
Date Tue, 13 May 2014 08:45:02 GMT
Author: desruisseaux
Date: Tue May 13 08:45:01 2014
New Revision: 1594155

URL: http://svn.apache.org/r1594155
Log:
Use IllegalArgumentException instead than planing to add an IllegalAttributeException.
If we want a more specific exception, we will define it in SIS rather than GeoAPI.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -109,13 +109,11 @@ public class DefaultAssociation extends 
      *
      * {@section Validation}
      * The amount of validation performed by this method is implementation dependent.
-     * The current {@code DefaultAssociation} implementation performs only very cheap (if
any) validations.
+     * The current {@code DefaultAssociation} implementation performs only very cheap validations.
      * A more exhaustive verification can be performed by invoking the {@link #validate()}
method.
      *
      * @param  value The new value, or {@code null}.
-     * @throws RuntimeException If this method performs validation and the given value does
not meet the conditions.
-     *         <span style="color:firebrick">This exception may be changed to {@code
IllegalPropertyException} in a
-     *         future SIS version.</span>
+     * @throws IllegalArgumentException If the given feature is not valid for this association.
      *
      * @see DefaultFeature#setPropertyValue(String, Object)
      */
@@ -124,7 +122,7 @@ public class DefaultAssociation extends 
             final DefaultFeatureType base = role.getValueType();
             final DefaultFeatureType type = value.getType();
             if (base != type && !base.maybeAssignableFrom(type)) {
-                throw new RuntimeException( // TODO: IllegalPropertyException, pending GeoAPI
revision.
+                throw new IllegalArgumentException(
                         Errors.format(Errors.Keys.IllegalArgumentClass_3, role.getName(),
base.getName(), type.getName()));
             }
         }
@@ -136,10 +134,6 @@ public class DefaultAssociation extends 
      * This method can be invoked explicitly on a single association, or may be invoked implicitly
by a call to
      * {@link DefaultFeature#validate()}.
      *
-     * @throws RuntimeException If the current association value violates a constraint.
-     *         <span style="color:firebrick">This exception will be changed to {@code
IllegalPropertyException}
-     *         in a future SIS version.</span>
-     *
      * @see DefaultFeature#validate()
      */
     @Override

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -114,15 +114,7 @@ public class DefaultAttribute<T> extends
     /**
      * Sets the attribute value.
      *
-     * {@section Validation}
-     * The amount of validation performed by this method is implementation dependent.
-     * The current {@code DefaultAttribute} implementation performs only very cheap (if any)
validations.
-     * A more exhaustive verification can be performed by invoking the {@link #validate()}
method.
-     *
-     * @param  value The new value.
-     * @throws RuntimeException If this method performs validation and the given value does
not meet the conditions.
-     *         <span style="color:firebrick">This exception will be changed to {@code
IllegalAttributeException} in a
-     *         future SIS version.</span>
+     * @param value The new value.
      *
      * @see DefaultFeature#setPropertyValue(String, Object)
      */
@@ -135,10 +127,6 @@ public class DefaultAttribute<T> extends
      * This method can be invoked explicitly on a single attribute, or may be invoked implicitly
by a call to
      * {@link DefaultFeature#validate()}.
      *
-     * @throws RuntimeException If the current attribute value violates a constraint.
-     *         <span style="color:firebrick">This exception will be changed to {@code
IllegalAttributeException}
-     *         in a future SIS version.</span>
-     *
      * @see DefaultFeature#validate()
      */
     @Override

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -227,9 +227,6 @@ public class DefaultFeature implements S
      * @param  value The new value for the given attribute (may be {@code null}).
      * @throws IllegalArgumentException If the given argument is not an attribute name of
this feature.
      * @throws ClassCastException If the value is not assignable to the expected value class.
-     * @throws RuntimeException If this method performs validation and the given value does
not meet the conditions.
-     *         <span style="color:firebrick">This exception will be changed to {@code
IllegalAttributeException} in
-     *         a future SIS version.</span>
      *
      * @see DefaultAttribute#setValue(Object)
      */
@@ -313,10 +310,6 @@ public class DefaultFeature implements S
      * Ensures that all current properties comply with the constraints defined by the feature
type.
      * This method will implicitly invokes {@link DefaultAttribute#validate()} for all attributes.
      *
-     * @throws RuntimeException If the current attribute value violates a constraint.
-     *         <span style="color:firebrick">This exception will be changed to {@code
IllegalAttributeException}
-     *         in a future SIS version.</span>
-     *
      * @see DefaultAttribute#validate()
      * @see DefaultAssociation#validate()
      */

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -40,8 +40,7 @@ final class Validator {
      */
     static void ensureValidType(final AbstractIdentifiedType type, final DefaultAttribute<?>
element) {
         if (element.getType() != type) {
-            // TODO: replace RuntimeException by IllegalAttributeException after GeoAPI review.
-            throw new RuntimeException(Errors.format(Errors.Keys.MismatchedPropertyType_1,
type.getName()));
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.MismatchedPropertyType_1,
type.getName()));
         }
     }
 
@@ -71,7 +70,7 @@ final class Validator {
          * so we are better to check.
          */
         if (!type.getValueClass().isInstance(value)) {
-            throw new RuntimeException( // TODO: IllegalAttributeException, pending GeoAPI
revision.
+            throw new IllegalStateException(
                     Errors.format(Errors.Keys.IllegalPropertyClass_2, type.getName(), value.getClass()));
         }
     }
@@ -85,7 +84,7 @@ final class Validator {
         }
         final DefaultFeatureType type = value.getType();
         if (!role.getValueType().isAssignableFrom(type)) {
-            throw new RuntimeException( // TODO: IllegalAttributeException, pending GeoAPI
revision.
+            throw new IllegalStateException(
                     Errors.format(Errors.Keys.IllegalPropertyClass_2, role.getName(), type.getName()));
         }
     }

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -63,7 +63,7 @@ public final strictfp class DefaultAssoc
                 singletonMap(DefaultFeatureType.NAME_KEY, "Population"), false, null, population));
         try {
             association.setValue(otherFeature);
-        } catch (RuntimeException e) { // TODO: IllegalPropertyException after we upgraded
GeoAPI.
+        } catch (IllegalArgumentException e) {
             final String message = e.getMessage();
             assertTrue(message, message.contains("Twin town"));
             assertTrue(message, message.contains("Population"));

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java?rev=1594155&r1=1594154&r2=1594155&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/PropertySingletonTest.java
[UTF-8] Tue May 13 08:45:01 2014
@@ -169,7 +169,7 @@ public final strictfp class PropertySing
         final DefaultAttribute<Integer> a1 = DefaultAttributeTest.population();
         try {
             singleton.add(a1);
-        } catch (RuntimeException e) { // TODO: IllegalAttributeException after GeoAPI review.
+        } catch (IllegalArgumentException e) {
             final String message = e.getMessage();
             assertTrue(message, message.contains(KEY));
         }



Mime
View raw message