sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1755368 - in /sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder: AssociationRoleBuilder.java AttributeTypeBuilder.java FeatureTypeBuilder.java OperationWrapper.java PropertyTypeBuilder.java
Date Fri, 05 Aug 2016 17:36:35 GMT
Author: desruisseaux
Date: Fri Aug  5 17:36:35 2016
New Revision: 1755368

URL: http://svn.apache.org/viewvc?rev=1755368&view=rev
Log:
Replace PropertyTypeBuilder.setCardinality(int,int) method by a pair of setMinimumOccurs(int)
/ setMaximumOccurs(int) method, together with their getter methods.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java?rev=1755368&r1=1755367&r2=1755368&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
[UTF-8] Fri Aug  5 17:36:35 2016
@@ -153,6 +153,34 @@ public final class AssociationRoleBuilde
     }
 
     /**
+     * Sets the minimum number of associations. If the given number is greater than the
+     * {@linkplain #getMaximumOccurs() maximal number} of associations, than the maximum
+     * is also set to that value.
+     *
+     * @param  occurs the new minimum number of associations.
+     * @return {@code this} for allowing method calls chaining.
+     */
+    @Override
+    public AssociationRoleBuilder setMinimumOccurs(final int occurs) {
+        super.setMinimumOccurs(occurs);
+        return this;
+    }
+
+    /**
+     * Sets the maximum number of associations. If the given number is less than the
+     * {@linkplain #getMinimumOccurs() minimal number} of associations, than the minimum
+     * is also set to that value.
+     *
+     * @param  occurs the new maximum number of associations.
+     * @return {@code this} for allowing method calls chaining.
+     */
+    @Override
+    public AssociationRoleBuilder setMaximumOccurs(final int occurs) {
+        super.setMaximumOccurs(occurs);
+        return this;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java?rev=1755368&r1=1755367&r2=1755368&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
[UTF-8] Fri Aug  5 17:36:35 2016
@@ -213,6 +213,34 @@ public final class AttributeTypeBuilder<
     }
 
     /**
+     * Sets the minimum number of attribute values. If the given number is greater than the
+     * {@linkplain #getMaximumOccurs() maximal number} of attribute values, than the maximum
+     * is also set to that value.
+     *
+     * @param  occurs the new minimum number of attribute values.
+     * @return {@code this} for allowing method calls chaining.
+     */
+    @Override
+    public AttributeTypeBuilder<V> setMinimumOccurs(final int occurs) {
+        super.setMinimumOccurs(occurs);
+        return this;
+    }
+
+    /**
+     * Sets the maximum number of attribute values. If the given number is less than the
+     * {@linkplain #getMinimumOccurs() minimal number} of attribute values, than the minimum
+     * is also set to that value.
+     *
+     * @param  occurs the new maximum number of attribute values.
+     * @return {@code this} for allowing method calls chaining.
+     */
+    @Override
+    public AttributeTypeBuilder<V> setMaximumOccurs(final int occurs) {
+        super.setMaximumOccurs(occurs);
+        return this;
+    }
+
+    /**
      * Returns the class of attribute values.
      *
      * @return the class of attribute values.

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java?rev=1755368&r1=1755367&r2=1755368&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] Fri Aug  5 17:36:35 2016
@@ -423,7 +423,8 @@ public class FeatureTypeBuilder extends
      * @param  maximumOccurs  new default maximum number of property values.
      * @return {@code this} for allowing method calls chaining.
      *
-     * @see AttributeTypeBuilder#setCardinality(int, int)
+     * @see PropertyTypeBuilder#setMinimumOccurs(int)
+     * @see PropertyTypeBuilder#setMaximumOccurs(int)
      */
     public FeatureTypeBuilder setDefaultCardinality(final int minimumOccurs, final int maximumOccurs)
{
         if (minimumOccurs < 0 || maximumOccurs < minimumOccurs) {

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java?rev=1755368&r1=1755367&r2=1755368&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/OperationWrapper.java
[UTF-8] Fri Aug  5 17:36:35 2016
@@ -58,7 +58,9 @@ final class OperationWrapper extends Pro
     /**
      * Do not allow a change of cardinality.
      */
-    @Override
+    @Override public PropertyTypeBuilder setMinimumOccurs(int occurs) {if (occurs == 1) return
this; throw readOnly();}
+    @Override public PropertyTypeBuilder setMaximumOccurs(int occurs) {if (occurs == 1) return
this; throw readOnly();}
+    @Override @Deprecated
     public PropertyTypeBuilder setCardinality(final int minimumOccurs, final int maximumOccurs)
{
         if (minimumOccurs != 1 || maximumOccurs != 1) {
             throw readOnly();

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java?rev=1755368&r1=1755367&r2=1755368&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java
[UTF-8] Fri Aug  5 17:36:35 2016
@@ -58,7 +58,7 @@ public abstract class PropertyTypeBuilde
      * The minimum number of property values.
      * The default value is 1, unless otherwise specified by {@link #setDefaultCardinality(int,
int)}.
      *
-     * @see #setCardinality(int, int)
+     * @see #getMinimumOccurs()
      */
     int minimumOccurs;
 
@@ -66,7 +66,7 @@ public abstract class PropertyTypeBuilde
      * The maximum number of property values.
      * The default value is 1, unless otherwise specified by {@link #setDefaultCardinality(int,
int)}.
      *
-     * @see #setCardinality(int, int)
+     * @see #getMaximumOccurs()
      */
     int maximumOccurs;
 
@@ -106,6 +106,79 @@ public abstract class PropertyTypeBuilde
     }
 
     /**
+     * Returns the minimum number of property values.
+     * The returned value is greater than or equal to zero.
+     *
+     * @return the minimum number of property values.
+     *
+     * @see org.apache.sis.feature.DefaultAttributeType#getMinimumOccurs()
+     */
+    public int getMinimumOccurs() {
+        return minimumOccurs;
+    }
+
+    /**
+     * Sets the minimum number of property values. If the given number is greater than the
+     * {@linkplain #getMaximumOccurs() maximal number} of property values, than the maximum
+     * is also set to that value.
+     *
+     * @param  occurs the new minimum number of property values.
+     * @return {@code this} for allowing method calls chaining.
+     *
+     * @see #getMinimumOccurs()
+     */
+    public PropertyTypeBuilder setMinimumOccurs(final int occurs) {
+        if (occurs != minimumOccurs) {
+            if (occurs < 0) {
+                throw new IllegalArgumentException(errors().getString(Errors.Keys.NegativeArgument_2,
"occurs", occurs));
+            }
+            minimumOccurs = occurs;
+            if (occurs > maximumOccurs) {
+                maximumOccurs = occurs;
+            }
+            clearCache();
+        }
+        return this;
+    }
+
+    /**
+     * Returns the maximum number of property values.
+     * The returned value is greater than or equal to the {@link #getMinimumOccurs()} value.
+     * If there is no maximum, then this method returns {@link Integer#MAX_VALUE}.
+     *
+     * @return the maximum number of property values, or {@link Integer#MAX_VALUE} if none.
+     *
+     * @see org.apache.sis.feature.DefaultAttributeType#getMaximumOccurs()
+     */
+    public final int getMaximumOccurs() {
+        return maximumOccurs;
+    }
+
+    /**
+     * Sets the maximum number of property values. If the given number is less than the
+     * {@linkplain #getMinimumOccurs() minimal number} of property values, than the minimum
+     * is also set to that value.
+     *
+     * @param  occurs the new maximum number of property values.
+     * @return {@code this} for allowing method calls chaining.
+     *
+     * @see #getMaximumOccurs()
+     */
+    public PropertyTypeBuilder setMaximumOccurs(final int occurs) {
+        if (occurs != maximumOccurs) {
+            if (occurs < 0) {
+                throw new IllegalArgumentException(errors().getString(Errors.Keys.NegativeArgument_2,
"occurs", occurs));
+            }
+            maximumOccurs = occurs;
+            if (occurs < minimumOccurs) {
+                minimumOccurs = occurs;
+            }
+            clearCache();
+        }
+        return this;
+    }
+
+    /**
      * Sets the minimum and maximum number of property values. Those numbers must be equal
or greater than zero.
      *
      * <p>If this method is not invoked, then the default values are the cardinality
specified by the last call
@@ -115,7 +188,10 @@ public abstract class PropertyTypeBuilde
      * @param  minimumOccurs  new minimum number of property values.
      * @param  maximumOccurs  new maximum number of property values.
      * @return {@code this} for allowing method calls chaining.
+     *
+     * @deprecated Replaced by {@link #setMinimumOccurs(int)} and {@link #setMaximumOccurs(int)}.
      */
+    @Deprecated
     @SuppressWarnings("unchecked")
     public PropertyTypeBuilder setCardinality(final int minimumOccurs, final int maximumOccurs)
{
         if (this.minimumOccurs != minimumOccurs || this.maximumOccurs != maximumOccurs) {



Mime
View raw message