sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1754273 - /sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
Date Wed, 27 Jul 2016 14:03:35 GMT
Author: desruisseaux
Date: Wed Jul 27 14:03:35 2016
New Revision: 1754273

URL: http://svn.apache.org/viewvc?rev=1754273&view=rev
Log:
Generalize the addOperation(Operation) method as an addProperty(PropertyType) method.

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

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=1754273&r1=1754272&r2=1754273&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] Wed Jul 27 14:03:35 2016
@@ -526,20 +526,36 @@ public class FeatureTypeBuilder extends
     }
 
     /**
-     * Adds the given operation in the feature type properties. The given operation object
will be added verbatim
-     * in the {@code FeatureType}; this builder does not create new operations.
+     * Adds the given property in the feature type properties.
+     * The given property shall be an instance of one of the following types:
+     * <ul>
+     *   <li>{@link AttributeType}, in which case this method delegate to {@link #addAttribute(AttributeType)}.</li>
+     *   <li>{@link FeatureAssociationRole}, in which case this method delegate to
{@link #addAssociation(FeatureAssociationRole)}.</li>
+     *   <li>{@link Operation}, in which case the given operation object will be added
verbatim in the {@code FeatureType};
+     *       this builder does not create new operations.</li>
+     * </ul>
      *
-     * @param  operation  the operation to add to the feature type.
-     * @return a read-only accessor on the operation properties.
+     * @param  template  the property to add to the feature type.
+     * @return a builder initialized to the given builder.
+     *         In the {@code Operation} case, the builder is a read-only accessor on the
operation properties.
      *
      * @see #properties()
      */
-    public PropertyTypeBuilder addOperation(final Operation operation) {
-        ensureNonNull("operation", operation);
-        final PropertyTypeBuilder property = new OperationWrapper(this, operation);
-        properties.add(property);
-        clearCache();
-        return property;
+    public PropertyTypeBuilder addProperty(final PropertyType template) {
+        ensureNonNull("template", template);
+        if (template instanceof AttributeType<?>) {
+            return addAttribute((AttributeType<?>) template);
+        } else if (template instanceof FeatureAssociationRole) {
+            return addAssociation((FeatureAssociationRole) template);
+        } else if (template instanceof Operation) {
+            final PropertyTypeBuilder property = new OperationWrapper(this, (Operation) template);
+            properties.add(property);
+            clearCache();
+            return property;
+        } else {
+            throw new IllegalArgumentException(errors().getString(
+                    Errors.Keys.IllegalArgumentClass_2, "template", template.getClass()));
+        }
     }
 
     /**



Mime
View raw message