Author: desruisseaux
Date: Mon Apr 18 20:47:50 2016
New Revision: 1739820

URL: http://svn.apache.org/viewvc?rev=1739820&view=rev
Log:
Start refactoring of FeatureTypeBuilder.
The plan is to replace the numerous 'addProperty' method by the creation of an 
inner class
dedicated to Attributes and Operations. This inner class will have its own set 
of 'setName'
methods together with some methods for marking it as default geometry, part of 
compound key,
etc.

Added:
    
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Builder.java
      - copied, changed from r1739766, 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
Modified:
    
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java
    
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
    
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/NameConvention.java
    
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/FeatureTypeBuilderTest.java
    
sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java

Modified: 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java?rev=1739820&r1=1739819&r2=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeTypeBuilder.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -22,14 +22,18 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.opengis.util.GenericName;
+import org.opengis.util.NameFactory;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.feature.DefaultAttributeType;
+
 import static org.apache.sis.feature.AbstractIdentifiedType.*;
 import static org.apache.sis.internal.feature.NameConvention.*;
-import org.apache.sis.internal.system.DefaultFactories;
+
+// Branch-dependent imports
 import org.opengis.feature.AttributeType;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.GenericName;
-import org.opengis.util.NameFactory;
+
 
 /**
  * Helper class for the creation of {@link AttributeType} instances.
@@ -44,12 +48,12 @@ import org.opengis.util.NameFactory;
  */
 public class AttributeTypeBuilder {
 
-    private final Map parameters = new HashMap();
-    private final List<AttributeType> atts = new ArrayList<>();
-    private Class valueClass = Object.class;
+    private final Map<String,Object> parameters = new HashMap<>();
+    private final List<AttributeType<?>> atts = new ArrayList<>();
+    private Class<?> valueClass = Object.class;
     private int minimumOccurs = 1;
     private int maximumOccurs = 1;
-    private Object defaultValue = null;
+    private Object defaultValue;
 
     /**
      * Reset builder parameters to there original values.
@@ -68,7 +72,7 @@ public class AttributeTypeBuilder {
      *
      * @param type attribute type to copy parameters from.
      */
-    public void copy(AttributeType type) {
+    public void copy(AttributeType<?> type) {
         setName(type.getName());
         setDefinition(type.getDefinition());
         setDescription(type.getDescription());
@@ -153,7 +157,7 @@ public class AttributeTypeBuilder {
      *
      * @param valueClass not null
      */
-    public void setValueClass(Class valueClass) {
+    public void setValueClass(Class<?> valueClass) {
         this.valueClass = valueClass;
     }
 
@@ -178,7 +182,7 @@ public class AttributeTypeBuilder {
     /**
      * Set maximum occurrences of the attribute values.
      *
-     * @param maximumOccurs must be positive and superior to minimum occurences
+     * @param maximumOccurs must be positive and superior to minimum 
occureences
      */
     public void setMaximumOccurs(int maximumOccurs) {
         this.maximumOccurs = maximumOccurs;
@@ -191,7 +195,7 @@ public class AttributeTypeBuilder {
      * @param length character sequence length
      * @return created characteristic
      */
-    public AttributeType setLengthCharacteristic(int length) {
+    public AttributeType<?> setLengthCharacteristic(int length) {
         return addCharacteristic(MAXIMAL_LENGTH_CHARACTERISTIC, Integer.class, 
1, 1, length);
     }
 
@@ -202,7 +206,7 @@ public class AttributeTypeBuilder {
      * @param crs geometry coordinate reference system
      * @return created characteristic
      */
-    public AttributeType setCRSCharacteristic(CoordinateReferenceSystem crs) {
+    public AttributeType<?> setCRSCharacteristic(CoordinateReferenceSystem 
crs) {
         return addCharacteristic(CRS_CHARACTERISTIC, 
CoordinateReferenceSystem.class, 1, 1, crs);
     }
 
@@ -213,7 +217,7 @@ public class AttributeTypeBuilder {
      * @param values enumeration of values
      * @return created characteristic
      */
-    public AttributeType setPossibleValues(Collection values) {
+    public AttributeType<?> setPossibleValues(Collection<?> values) {
         return addCharacteristic(VALID_VALUES_CHARACTERISTIC, Object.class, 1, 
1, values);
     }
 
@@ -227,7 +231,7 @@ public class AttributeTypeBuilder {
      * @param defaultValue characteristic default value
      * @return created characteristic
      */
-    public AttributeType addCharacteristic(String localPart, Class valueClass, 
int minimumOccurs, int maximumOccurs, Object defaultValue) {
+    public AttributeType<?> addCharacteristic(String localPart, Class<?> 
valueClass, int minimumOccurs, int maximumOccurs, Object defaultValue) {
         final NameFactory factory = 
DefaultFactories.forBuildin(NameFactory.class);
         final GenericName name = factory.createGenericName(null, localPart);
         return 
addCharacteristic(name,valueClass,minimumOccurs,maximumOccurs,defaultValue);
@@ -243,7 +247,7 @@ public class AttributeTypeBuilder {
      * @param defaultValue characteristic default value
      * @return created characteristic
      */
-    public AttributeType addCharacteristic(GenericName name, Class valueClass, 
int minimumOccurs, int maximumOccurs, Object defaultValue) {
+    public AttributeType<?> addCharacteristic(GenericName name, Class<?> 
valueClass, int minimumOccurs, int maximumOccurs, Object defaultValue) {
         return addCharacteristic(new DefaultAttributeType(
                     Collections.singletonMap(NAME_KEY, name),
                     valueClass,minimumOccurs,maximumOccurs,defaultValue));
@@ -255,9 +259,9 @@ public class AttributeTypeBuilder {
      * @param characteristic not null
      * @return added characteristic
      */
-    public AttributeType addCharacteristic(AttributeType characteristic) {
+    public AttributeType<?> addCharacteristic(AttributeType<?> characteristic) 
{
         //search and remove previous characteristic with the same id if it 
exist
-        for(AttributeType at : atts) {
+        for (AttributeType<?> at : atts) {
             if(at.getName().equals(characteristic.getName())) {
                 atts.remove(at);
                 break;
@@ -272,10 +276,9 @@ public class AttributeTypeBuilder {
      *
      * @return AtributeType, never null
      */
-    public AttributeType build() {
+    public AttributeType<?> build() {
         return new DefaultAttributeType(parameters, valueClass,
                 minimumOccurs, maximumOccurs,
-                defaultValue, atts.toArray(new AttributeType[atts.size()]));
+                defaultValue, atts.toArray(new AttributeType<?>[atts.size()]));
     }
-
 }

Copied: 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Builder.java
 (from r1739766, 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java)
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Builder.java?p2=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Builder.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java&r1=1739766&r2=1739820&rev=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Builder.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -16,821 +16,154 @@
  */
 package org.apache.sis.internal.feature;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import org.opengis.util.GenericName;
-import org.opengis.util.NameFactory;
-import org.opengis.util.ScopedName;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.feature.AbstractOperation;
-import org.apache.sis.feature.DefaultAssociationRole;
-import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.feature.DefaultFeatureType;
-import org.apache.sis.feature.FeatureOperations;
-import org.apache.sis.internal.system.DefaultFactories;
-
-import static org.apache.sis.internal.feature.NameConvention.*;
-import static org.apache.sis.feature.DefaultFeatureType.*;
+import org.apache.sis.util.ArgumentChecks;
 
 // Branch-dependent imports
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.FeatureAssociationRole;
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyType;
+import org.opengis.feature.IdentifiedType;
 
 
 /**
- * Helper class for the creation of {@link FeatureType} instances.
- * This builder can create the parameters to be given to {@linkplain 
DefaultFeatureType feature type constructor}
- * from simpler parameters given to this builder.
+ * Base class of feature and attribute builders.
+ * This base class provide the method needed for filling the {@code 
identification} map.
  *
  * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-public class FeatureTypeBuilder {
-
-    private final Map<GenericName,PropertyType> properties = new 
LinkedHashMap<>();
-    private final List<FeatureType> superTypes = new ArrayList<>();
-    private boolean isAbstract = false;
-    private final Map<String,Object> parameters = new HashMap<>();
-
-    //convention ID
-    private String idPrefix = null;
-    private String idSeparator = null;
-    private GenericName[] idAttributes = null;
-    //convention default geometry
-    private GenericName defGeomAttribute = null;
-
-    /**
-     * Reset builder parameters to there original values.
-     */
-    public void reset() {
-        properties.clear();
-        superTypes.clear();
-        isAbstract = false;
-        parameters.clear();
-        idPrefix = null;
-        idSeparator = null;
-        idAttributes = null;
-        defGeomAttribute = null;
-    }
-
+abstract class Builder {
     /**
-     * Copy parameters from the given feature type.
-     *
-     * @param type feature type to copy parameters from.
+     * The feature name, definition, designation and description.
+     * The name is mandatory; all other information are optional.
      */
-    public void copy(final FeatureType type) {
-        reset();
-        setName(type.getName());
-        setDescription(type.getDescription());
-        setDefinition(type.getDefinition());
-        setDesignation(type.getDesignation());
-        setAbstract(type.isAbstract());
-        setSuperTypes(type.getSuperTypes());
-
-        for (PropertyType pt : type.getProperties(false)) {
-            addProperty(pt);
-        }
-    }
+    final Map<String,Object> identification = new HashMap<>();
 
     /**
-     * Set feature type name.
-     *
-     * @param localPart generic name tip part, not null
+     * Creates a new builder instance.
      */
-    public void setName(String localPart) {
-        setName(create(localPart));
+    Builder() {
     }
 
     /**
-     * Set feature type name.
-     *
-     * @param scope generic name scope part, can be null
-     * @param localPart generic name tip part, not null
+     * Resets this builder to its initial state. After invocation of this 
method,
+     * this builder is in the same state than after construction.
      */
-    public void setName(String scope, String localPart) {
-        setName(create(scope,localPart));
+    public void clear() {
+        identification.clear();
     }
 
     /**
-     * Set feature type name.
-     *
-     * See {@link #NAME_KEY}
-     *
-     * @param name generic name, not null
+     * Sets this builder state to properties inferred from the given type.
      */
-    public void setName(GenericName name) {
-        parameters.put(NAME_KEY, name);
+    final void copy(final IdentifiedType template) {
+        clear();
+        setName       (template.getName());
+        setDescription(template.getDescription());
+        setDefinition (template.getDefinition());
+        setDesignation(template.getDesignation());
     }
 
     /**
-     * Return the current feature type name.
+     * Sets the feature type name as a simple string without scope.
+     * The name will be an instance of {@link org.opengis.util.LocalName}.
      *
-     * @return GenericName, can be null
-     */
-    public GenericName getName() {
-        Object val = parameters.get(DefaultFeatureType.NAME_KEY);
-        if (val instanceof GenericName) {
-            return (GenericName) val;
-        } else if (val instanceof String) {
-            return valueOf((String) val);
-        }
-        return null;
-    }
-
-    /**
-     * Set attribute description.
-     *
-     * See {@link #DESCRIPTION_KEY}
-     *
-     * @param description feature type description
-     */
-    public void setDescription(CharSequence description) {
-        parameters.put(DESCRIPTION_KEY, description);
-    }
-
-    /**
-     * Set attribute designation.
-     *
-     * See {@link #DESIGNATION_KEY}
-     *
-     * @param designation feature type designation
-     */
-    public void setDesignation(CharSequence designation) {
-        parameters.put(DESIGNATION_KEY, designation);
-    }
-
-    /**
-     * Set attribute definition.
-     *
-     * See {@link #DEFINITION_KEY}
-     *
-     * @param definition feature type definition
-     */
-    public void setDefinition(CharSequence definition) {
-        parameters.put(DEFINITION_KEY, definition);
-    }
-
-    /**
-     * Set feature type abstract.
-     *
-     * @param isAbstract whether the feature is abstract.
-     */
-    public void setAbstract(final boolean isAbstract) {
-        this.isAbstract = isAbstract;
-    }
-
-    /**
-     * Set parent types.
-     * Feature type will inherit all parent properties.
-     *
-     * @param types not null
-     */
-    public void setSuperTypes(final Collection<? extends FeatureType> types) {
-        superTypes.clear();
-        superTypes.addAll(types);
-    }
-
-    /**
-     * Set parent types.
-     * Feature type will inherit all parent properties.
+     * <p>This convenience method creates a {@link GenericName} instance,
+     * then delegates to {@link #setName(GenericName)}.</p>
      *
-     * @param types not null
-     */
-    public void setSuperTypes(final FeatureType... types) {
-        superTypes.clear();
-        superTypes.addAll(Arrays.asList(types));
-    }
-
-    /**
-     * Define an id operation composed of the given attribute.
-     * Generated id prefix will be the name of the featuretype+'.'
-     *
-     * @param attributeName attribute id used in the id operation
-     */
-    public void setIdOperation(final String attributeName) {
-        setIdOperation(null, "-", create(attributeName));
-    }
-
-    /**
-     * Define an id operation composed of the given attributes.
-     * Generated id prefix will be the name of the featuretype+'.'
-     *
-     * @param attributes attributes used in the id operation
-     */
-    public void setIdOperation(final GenericName ... attributes) {
-        setIdOperation(null, "-", attributes);
-    }
-
-    /**
-     * Define an id operation composed of the given attribute.
-     *
-     * @param prefix generated id prefix
-     * @param attributeName attribute id used in the id operation
-     */
-    public void setIdOperation(final String prefix, final String 
attributeName) {
-        setIdOperation(prefix, "-", create(attributeName));
-    }
-
-    /**
-     * Define an id operation composed of the given attributes.
-     *
-     * @param prefix generated id prefix
-     * @param attributes attributes used in the id operation
-     */
-    public void setIdOperation(final String prefix, final GenericName ... 
attributes) {
-        setIdOperation(prefix, "-", attributes);
-    }
-
-    /**
-     * Define an id operation composed of the given attributes.
-     *
-     * @param prefix generated id prefix
-     * @param separator generated id separator between attribute values
-     * @param attributes attributes used in the id operation
-     */
-    public void setIdOperation(final String prefix, final String separator, 
final GenericName ... attributes) {
-        idPrefix = prefix;
-        idSeparator = separator;
-        idAttributes = attributes;
-        //add placeholder
-        properties.put(ID_PROPERTY, null);
-    }
-
-    /**
-     * Define a default geometry link operation.
-     *
-     * @param attribute referenced attribute
-     */
-    public void setDefaultGeometryOperation(final String attribute) {
-        setDefaultGeometryOperation(create(attribute));
-    }
-
-    /**
-     * Define a default geometry link operation.
-     *
-     * @param scope referenced attribute name scope
-     * @param localPart referenced name tip
-     */
-    public void setDefaultGeometryOperation(final String scope, final String 
localPart) {
-        setDefaultGeometryOperation(create(scope,localPart));
-    }
-
-    /**
-     * Define a default geometry link operation.
-     *
-     * @param attribute referenced attribute
-     */
-    public void setDefaultGeometryOperation(final GenericName attribute) {
-        defGeomAttribute = attribute;
-        //add placeholder
-        properties.put(DEFAULT_GEOMETRY_PROPERTY, null);
-        properties.put(ENVELOPE_PROPERTY, null);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no 
characteristics
-     * and no default value.
-     *
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String localPart, final 
Class<V> valueClass) {
-        return addProperty(create(localPart), valueClass);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no 
characteristics
-     * and no default value.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass) {
-        return addProperty(create(scope, localPart), valueClass);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no 
characteristics
-     * and no default value.
-     *
-     * @param name property name
-     * @param valueClass property value class
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass) {
-        return addProperty(name, valueClass, (V) null);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no default 
value
-     * and the given {@code CoordinateReferenceSystem} characteristic.
-     *
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
+     * @param localPart  the local part of the generic name (can not be {@code 
null}).
      */
-    public <V> AttributeType<V> addProperty(final String localPart, final 
Class<V> valueClass, final CoordinateReferenceSystem crs) {
-        return addProperty(null, localPart, valueClass, crs);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no default 
value
-     * and the given {@code CoordinateReferenceSystem} characteristic.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
-            final Class<V> valueClass, final CoordinateReferenceSystem crs)
-    {
-        return addProperty(create(scope, localPart), valueClass, crs);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one, no default 
value
-     * and the given {@code CoordinateReferenceSystem} characteristic.
-     *
-     * @param name property name
-     * @param valueClass property value class
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass, final CoordinateReferenceSystem crs) {
-        return addProperty(name, valueClass, null, crs);
+    public void setName(String localPart) {
+        ArgumentChecks.ensureNonNull("localPart", localPart);
+        setName(name(null, localPart));
     }
 
     /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one and no 
characteristics.
+     * Sets the feature type name as a string in the given scope.
+     * If the given scope is non-null, then the name will be an instance of 
{@link org.opengis.util.ScopedName}.
      *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param defaultValue property default value
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
-            final Class<V> valueClass, final V defaultValue)
-    {
-        return addProperty(create(scope, localPart), valueClass, defaultValue, 
null);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one and the given
-     * {@code CoordinateReferenceSystem} characteristic.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param defaultValue property default value
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
-            final Class<V> valueClass, final V defaultValue, final 
CoordinateReferenceSystem crs)
-    {
-        return addProperty(create(scope, localPart), valueClass, 1, 1, 
defaultValue, crs);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one and no 
characteristics.
+     * <p>This convenience method creates a {@link GenericName} instance,
+     * then delegates to {@link #setName(GenericName)}.</p>
      *
-     * @param name property name
-     * @param valueClass property value class
-     * @param defaultValue property default value
-     * @return created property type
+     * @param scope      the scope of the name to create, or {@code null} if 
the name is local.
+     * @param localPart  the local part of the generic name (can not be {@code 
null}).
      */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass, final V defaultValue) {
-        return addProperty(name, valueClass, 1, 1, defaultValue);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     * Property will have a minimum and maximum occurrence of one and the given
-     * {@code CoordinateReferenceSystem} characteristic.
-     *
-     * @param name property name
-     * @param valueClass property value class
-     * @param defaultValue property default value
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass,
-            final V defaultValue, final CoordinateReferenceSystem crs)
-    {
-        return addProperty(name, valueClass, 1, 1, defaultValue, crs);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     *
-     *
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @param defaultValue property default value
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String localPart, final 
Class<V> valueClass,
-            final int minimumOccurs, final int maximumOccurs, final V 
defaultValue)
-    {
-        return addProperty(create(localPart), valueClass, minimumOccurs, 
maximumOccurs, defaultValue);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @param defaultValue property default value
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass,
-            final int minimumOccurs, final int maximumOccurs, final V 
defaultValue)
-    {
-        return addProperty(create(scope, localPart), valueClass, 
minimumOccurs, maximumOccurs, defaultValue);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param valueClass property value class
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @param defaultValue property default value
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass,
-            final int minimumOccurs, final int maximumOccurs, final V 
defaultValue, final CoordinateReferenceSystem crs)
-    {
-        return addProperty(create(scope, localPart), valueClass, 
minimumOccurs, maximumOccurs, defaultValue, crs);
-    }
-
-    /**
-     * Add a new property to the feature type.
-     *
-     * @param name property name
-     * @param valueClass property value class
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @param defaultValue property default value
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass,
-            final int minimumOccurs, final int maximumOccurs, final V 
defaultValue)
-    {
-        return addProperty(name, valueClass, minimumOccurs, maximumOccurs, 
defaultValue,null);
+    public void setName(String scope, String localPart) {
+        ArgumentChecks.ensureNonNull("localPart", localPart);
+        setName(name(scope, localPart));
     }
 
     /**
-     * Add a new property to the feature type.
+     * Sets the feature type name as a generic name.
+     * If another name was defined before this method call, that previous 
value will be discarded.
      *
-     * @param name property name
-     * @param valueClass property value class
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @param defaultValue property default value
-     * @param crs property {@code CoordinateReferenceSystem} characteristic
-     * @return created property type
-     */
-    public <V> AttributeType<V> addProperty(final GenericName name, final 
Class<V> valueClass,
-            final int minimumOccurs, final int maximumOccurs, final V 
defaultValue, final CoordinateReferenceSystem crs)
-    {
-        final AttributeType<V> att;
-        if (crs != null) {
-            final AttributeType<CoordinateReferenceSystem> qualifier = new 
DefaultAttributeType<>(
-                    Collections.singletonMap(NAME_KEY, CRS_CHARACTERISTIC),
-                    CoordinateReferenceSystem.class, 1, 1, crs);
-            att = new DefaultAttributeType<>(
-                Collections.singletonMap(NAME_KEY, name),
-                valueClass, minimumOccurs, maximumOccurs, defaultValue, 
qualifier);
-        } else {
-            att = new DefaultAttributeType<>(
-                Collections.singletonMap(NAME_KEY, name),
-                valueClass, minimumOccurs, maximumOccurs, defaultValue);
-        }
-        addProperty(att);
-        return att;
-    }
-
-    /**
-     * Add a custom property to the feature type.
+     * <div class="note"><b>Note for subclasses:</b>
+     * all {@code setName(…)} convenience methods in this builder delegate to 
this method.
+     * Consequently this method can be used as a central place where to 
control the creation of all names.</div>
      *
-     * @param property user defined property type
-     * @return created property type
-     */
-    public PropertyType addProperty(final PropertyType property) {
-        properties.put(property.getName(), property);
-        return property;
-    }
-
-    /**
-     * Add a new association to the feature type.
-     * Association will have a minimum occurrence of zero and maximum 
occurrence of one.
+     * @param name  the generic name (can not be {@code null}).
      *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param type associated feature type
-     * @return created association
+     * @see DefaultFeatureType#NAME_KEY
      */
-    public FeatureAssociationRole addAssociation(final String scope, final 
String localPart, final FeatureType type) {
-        return addAssociation(scope, localPart, type,0,1);
+    public void setName(GenericName name) {
+        ArgumentChecks.ensureNonNull("name", name);
+        identification.put(DefaultFeatureType.NAME_KEY, name);
     }
 
     /**
-     * Add a new association to the feature type.
-     * Association will have a minimum occurrence of zero and maximum 
occurrence of one.
+     * Returns the current {@code FeatureType} name, or {@code null} if 
undefined.
+     * This method returns the value built from the last call to a {@code 
setName(…)} method.
      *
-     * @param name property name
-     * @param type associated feature type
-     * @return created association
+     * @return the current {@code FeatureType} name, or {@code null} if the 
name has not yet been specified.
      */
-    public FeatureAssociationRole addAssociation(final GenericName name, final 
FeatureType type) {
-        return addAssociation(name, type,0,1);
-    }
-
-    /**
-     * Add a new association to the feature type.
-     *
-     * @param scope property generic name scope part
-     * @param localPart property generic name tip part
-     * @param type associated feature type
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @return created association
-     */
-    public FeatureAssociationRole addAssociation(final String scope, final 
String localPart, final FeatureType type,
-            final int minimumOccurs, final int maximumOccurs)
-    {
-        return addAssociation(create(scope, localPart), type,minimumOccurs, 
maximumOccurs);
-    }
-
-    /**
-     * Add a new association to the feature type.
-     *
-     * @param name property name
-     * @param type associated feature type
-     * @param minimumOccurs property minimum number of occurrences
-     * @param maximumOccurs property maximum number of occurrences
-     * @return created association
-     */
-    public FeatureAssociationRole addAssociation(final GenericName name, final 
FeatureType type,
-            final int minimumOccurs, final int maximumOccurs)
-    {
-        final FeatureAssociationRole role = new DefaultAssociationRole(
-                Collections.singletonMap(NAME_KEY, name), type, minimumOccurs, 
maximumOccurs);
-        addProperty(role);
-        return role;
+    public GenericName getName() {
+        return (GenericName) identification.get(DefaultFeatureType.NAME_KEY);
     }
 
     /**
-     * Add a custom properties to the feature type.
+     * Sets optional information beyond that required for concise definition 
of the element.
+     * The description may assist in understanding the feature scope and 
application.
      *
-     * @param properties user defined property types
-     */
-    public void addProperties(final PropertyType ... properties) {
-        for (PropertyType pt : properties) {
-            this.properties.put(pt.getName(), pt);
-        }
-    }
-
-    /**
-     * Add a custom properties to the feature type.
+     * @param description  information beyond that required for concise 
definition of the element, or {@code null} if none.
      *
-     * @param properties user defined property types
+     * @see DefaultFeatureType#DESCRIPTION_KEY
      */
-    public void addProperties(final Collection<? extends PropertyType> 
properties) {
-        for (PropertyType pt : properties) {
-            this.properties.put(pt.getName(), pt);
-        }
+    public void setDescription(CharSequence description) {
+        identification.put(DefaultFeatureType.DESCRIPTION_KEY, description);
     }
 
     /**
-     * Remove a property from the feature type.
+     * Sets a natural language designator for the element.
+     * This can be used as an alternative to the {@linkplain #getName() name} 
in user interfaces.
      *
-     * @param name property name
-     * @return removed property, can be null if property was not found
-     */
-    public PropertyType removeProperty(final String name) {
-        return properties.remove(valueOf(name));
-    }
-
-    /**
-     * Remove a property from the feature type.
+     * @param designation a natural language designator for the element, or 
{@code null} if none.
      *
-     * @param name property name
-     * @return removed property, can be null if property was not found
+     * @see DefaultFeatureType#DESIGNATION_KEY
      */
-    public PropertyType removeProperty(final GenericName name) {
-        return properties.remove(name);
+    public void setDesignation(CharSequence designation) {
+        identification.put(DefaultFeatureType.DESIGNATION_KEY, designation);
     }
 
     /**
-     * Build feature type
+     * Sets a concise definition of the element.
      *
-     * @return FeatureType
-     */
-    public DefaultFeatureType build() throws IllegalArgumentException {
-        //build id property
-        if (idAttributes != null) {
-            //check id properties exist
-            for (GenericName n : idAttributes) {
-                if (!properties.containsKey(n)) {
-                    throw new IllegalArgumentException("Property "+n+" used in 
id does not exist");
-                }
-            }
-
-            String prefix = idPrefix;
-            if (idPrefix==null) {
-                prefix = getName().tip().toString();
-            }
-
-            final Operation att = FeatureOperations.compound(
-                    Collections.singletonMap(AbstractOperation.NAME_KEY, 
ID_PROPERTY),
-                    idSeparator, prefix, null, properties.get(idAttributes));
-            properties.put(ID_PROPERTY, att);
-        }
-        //build default geometry property
-        if (defGeomAttribute != null) {
-            if (!properties.containsKey(defGeomAttribute)) {
-                throw new IllegalArgumentException("Property 
"+defGeomAttribute+" used in default geometry does not exist");
-            }
-            final PropertyType geomAtt = properties.get(defGeomAttribute);
-            final CoordinateReferenceSystem crs = null; // TODO 
NameConvention.getCoordinateReferenceSystem(geomAtt);
-            final Operation att = FeatureOperations.link(
-                    Collections.singletonMap(AbstractOperation.NAME_KEY, 
DEFAULT_GEOMETRY_PROPERTY), geomAtt);
-            properties.put(DEFAULT_GEOMETRY_PROPERTY, att);
-
-            // TODO
-//            final Operation boundAtt = 
FeatureOperations.bounds(Collections.singletonMap(AbstractOperation.NAME_KEY, 
ENVELOPE_PROPERTY), null, crs);
-//            properties.put(ENVELOPE_PROPERTY, boundAtt);
-
-        }
-
-        verifyOperations();
-
-        return new DefaultFeatureType(
-                parameters,
-                isAbstract,
-                superTypes.toArray(new FeatureType[superTypes.size()]),
-                properties.values().toArray(new 
PropertyType[properties.size()]));
-    }
-
-    /**
-     * Check operations have the required properties.
+     * @param definition a concise definition of the element, or {@code null} 
if none.
      *
-     * @throws IllegalArgumentException if some properties are missing for an 
operation.
+     * @see DefaultFeatureType#DEFINITION_KEY
      */
-    private void verifyOperations() throws IllegalArgumentException {
-        for (PropertyType pt : properties.values()) {
-            if (pt instanceof AbstractOperation) {
-                final Set<String> dependencies = 
((AbstractOperation)pt).getDependencies();
-                depLoop:
-                for (String dep : dependencies) {
-                    for (GenericName gn : properties.keySet()) {
-                        if (match(gn, dep)) continue depLoop;
-                    }
-                    throw new IllegalArgumentException("Operation 
"+pt.getName().toString()+" requiere property "+dep+" but this property is 
missing.");
-                }
-
-            }
-        }
-
-    }
-
-    
////////////////////////////////////////////////////////////////////////////
-    // Name utils 
//////////////////////////////////////////////////////////////
-    
////////////////////////////////////////////////////////////////////////////
-
-
-    private static GenericName create(final String local) {
-        return create(null,local);
+    public void setDefinition(CharSequence definition) {
+        identification.put(DefaultFeatureType.DEFINITION_KEY, definition);
     }
 
     /**
+     * Creates a generic name from the given scope and local part.
      *
-     * @param parsedNames mandatory
-     * @return GenericName
+     * @param scope      the scope of the name to create, or {@code null} if 
the name is local.
+     * @param localPart  the local part of the generic name (can not be {@code 
null}).
      */
-    private static GenericName create(final String scope, final String 
localPart) {
-        if (scope == null) {
-            return 
DefaultFactories.forBuildin(NameFactory.class).createGenericName(null, 
localPart);
-        } else {
-            return 
DefaultFactories.forBuildin(NameFactory.class).createGenericName(null, scope, 
localPart);
-        }
-    }
-
-    /**
-     * Parse a string value that can be expressed in 2 different forms :
-     * JSR-283 extended form : {uri}localpart
-     * Separator form : uri:localpart
-     *
-     * if the given string do not match any, then a Name with no namespace 
will be
-     * created and the localpart will be the given string.
-     *
-     * @param candidate String to convert to a geoneric name
-     * @return Name
-     */
-    private static GenericName valueOf(final String candidate) {
-
-        if (candidate.startsWith("{")) {
-            //name is in extended form
-            return toSessionNamespaceFromExtended(candidate);
-        }
-
-        int index = candidate.lastIndexOf(':');
-
-        if (index <= 0) {
-            return create(null, candidate);
-        } else {
-            final String uri = candidate.substring(0,index);
-            final String name = 
candidate.substring(index+1,candidate.length());
-            return create(uri, name);
-        }
-
-    }
-
-    private static GenericName toSessionNamespaceFromExtended(final String 
candidate) {
-        final int index = candidate.indexOf('}');
-
-        if (index < 0) throw new IllegalArgumentException("Invalide extended 
form : "+ candidate);
-
-        final String uri = candidate.substring(1, index);
-        final String name = candidate.substring(index+1, candidate.length());
-
-        return create(uri, name);
-    }
-
-    private static String toExpandedString(final GenericName name) {
-        String ns = getNamespace(name);
-        if (ns == null) {
-            return name.tip().toString();
-        } else {
-            return '{' + ns + '}' + name.tip();
-        }
-    }
-
-    /**
-     * Tests that the given string representation matches the given name.
-     * String can be written with only the local part or in extendedform or JCR
-     * extended form.
-     *
-     * @param name expected generic name
-     * @param candidate name to test
-     * @return true if the string match the name
-     */
-    private static boolean match(final GenericName name, final String 
candidate) {
-        if (candidate.startsWith("{")) {
-            //candidate is in extended form
-            return candidate.equals(toExpandedString(name));
-        }
-
-        final int index = candidate.lastIndexOf(':');
-
-        if (index <= 0) {
-            return candidate.equals(name.tip().toString());
-        } else {
-            final String uri = candidate.substring(0,index);
-            final String local = 
candidate.substring(index+1,candidate.length());
-            return uri.equals(getNamespace(name)) && 
local.equals(name.tip().toString());
-        }
-    }
-
-    private static String getNamespace(final GenericName name) {
-        return (name instanceof ScopedName) ? 
((ScopedName)name).path().toString() : null;
-    }
+    abstract GenericName name(String scope, String localPart);
 }

Modified: 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java?rev=1739820&r1=1739819&r2=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureTypeBuilder.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -20,7 +20,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -28,6 +27,7 @@ import java.util.Set;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
 import org.opengis.util.ScopedName;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.feature.AbstractOperation;
 import org.apache.sis.feature.DefaultAssociationRole;
@@ -35,9 +35,9 @@ import org.apache.sis.feature.DefaultAtt
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.feature.FeatureOperations;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.util.ArgumentChecks;
 
 import static org.apache.sis.internal.feature.NameConvention.*;
-import static org.apache.sis.feature.DefaultFeatureType.*;
 
 // Branch-dependent imports
 import org.opengis.feature.AttributeType;
@@ -49,208 +49,126 @@ import org.opengis.feature.PropertyType;
 
 /**
  * Helper class for the creation of {@link FeatureType} instances.
- * This builder can create the parameters to be given to {@linkplain 
DefaultFeatureType feature type constructor}
- * from simpler parameters given to this builder.
+ * This builder can create the parameters to be given to the {@linkplain 
DefaultFeatureType#DefaultFeatureType
+ * feature type constructor} from simpler parameters given to this builder.
+ *
+ * <p>{@code FeatureTypeBuilder} should be short lived.
+ * After the {@code FeatureType} has been created, the builder should be 
discarded.</p>
  *
  * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
  * @version 0.7
  * @module
  */
-public class FeatureTypeBuilder {
-
-    private final Map<GenericName,PropertyType> properties = new 
LinkedHashMap<>();
-    private final List<FeatureType> superTypes = new ArrayList<>();
-    private boolean isAbstract = false;
-    private final Map<String,Object> parameters = new HashMap<>();
-
-    //convention ID
-    private String idPrefix = null;
-    private String idSeparator = null;
-    private GenericName[] idAttributes = null;
-    //convention default geometry
-    private GenericName defGeomAttribute = null;
-
-    /**
-     * Reset builder parameters to there original values.
-     */
-    public void reset() {
-        properties.clear();
-        superTypes.clear();
-        isAbstract = false;
-        parameters.clear();
-        idPrefix = null;
-        idSeparator = null;
-        idAttributes = null;
-        defGeomAttribute = null;
-    }
-
+public class FeatureTypeBuilder extends Builder {
     /**
-     * Copy parameters from the given feature type.
-     *
-     * @param type feature type to copy parameters from.
+     * The factory to use for creating names.
      */
-    public void copy(final FeatureType type) {
-        reset();
-        setName(type.getName());
-        setDescription(type.getDescription());
-        setDefinition(type.getDefinition());
-        setDesignation(type.getDesignation());
-        setAbstract(type.isAbstract());
-        setSuperTypes(type.getSuperTypes());
-
-        for (PropertyType pt : type.getProperties(false)) {
-            addProperty(pt);
-        }
-    }
+    private final NameFactory nameFactory;
 
     /**
-     * Set feature type name.
-     *
-     * @param localPart generic name tip part, not null
+     * The feature properties. Entries in this map are added by invoking one 
of the
+     * {@code addProperty(…)} methods defined in this class.
      */
-    public void setName(String localPart) {
-        setName(create(localPart));
-    }
-
-    /**
-     * Set feature type name.
-     *
-     * @param scope generic name scope part, can be null
-     * @param localPart generic name tip part, not null
-     */
-    public void setName(String scope, String localPart) {
-        setName(create(scope,localPart));
-    }
+    private final Map<GenericName,PropertyType> properties = new 
LinkedHashMap<>();
 
     /**
-     * Set feature type name.
-     *
-     * See {@link #NAME_KEY}
-     *
-     * @param name generic name, not null
+     * The parent of the feature to create. By default, new features have no 
parent.
      */
-    public void setName(GenericName name) {
-        parameters.put(NAME_KEY, name);
-    }
+    private final List<FeatureType> superTypes = new ArrayList<>();
 
     /**
-     * Return the current feature type name.
-     *
-     * @return GenericName, can be null
+     * Whether the feature type is abstract. The default value is {@code 
false}.
      */
-    public GenericName getName() {
-        Object val = parameters.get(DefaultFeatureType.NAME_KEY);
-        if (val instanceof GenericName) {
-            return (GenericName) val;
-        } else if (val instanceof String) {
-            return valueOf((String) val);
-        }
-        return null;
-    }
+    private boolean isAbstract;
 
     /**
-     * Set attribute description.
-     *
-     * See {@link #DESCRIPTION_KEY}
-     *
-     * @param description feature type description
+     * If {@link #idAttributes} is non-null, an optional prefix to insert 
before the
+     * {@linkplain FeatureOperations#compound compound key} named {@code 
"@id"}.
      */
-    public void setDescription(CharSequence description) {
-        parameters.put(DESCRIPTION_KEY, description);
-    }
+    private String idPrefix;
 
     /**
-     * Set attribute designation.
-     *
-     * See {@link #DESIGNATION_KEY}
-     *
-     * @param designation feature type designation
+     * If {@link #idAttributes} is non-null and contains more than one value, 
the separator to insert between
+     * each single component in a {@linkplain FeatureOperations#compound 
compound key} named {@code "@id"}.
      */
-    public void setDesignation(CharSequence designation) {
-        parameters.put(DESIGNATION_KEY, designation);
-    }
+    private String idDelimiter;
 
     /**
-     * Set attribute definition.
-     *
-     * See {@link #DEFINITION_KEY}
-     *
-     * @param definition feature type definition
+     * The names of attributes to use in a {@linkplain 
FeatureOperations#compound compound key} named {@code "@id"},
+     * or {@code null} if none. If this array contains only one name and 
{@link #idPrefix} is null, then {@code "@id"}
+     * will be a {@linkplain FeatureOperations#link link} to the attribute 
named {@code idAttributes[0]}.
      */
-    public void setDefinition(CharSequence definition) {
-        parameters.put(DEFINITION_KEY, definition);
-    }
+    private GenericName[] idAttributes;
 
     /**
-     * Set feature type abstract.
-     *
-     * @param isAbstract whether the feature is abstract.
+     * The name of the default geometry attribute, or {@code null} if none.
      */
-    public void setAbstract(final boolean isAbstract) {
-        this.isAbstract = isAbstract;
-    }
+    private GenericName defGeomAttribute;
 
     /**
-     * Set parent types.
-     * Feature type will inherit all parent properties.
-     *
-     * @param types not null
+     * Creates a new builder instance.
      */
-    public void setSuperTypes(final Collection<? extends FeatureType> types) {
-        superTypes.clear();
-        superTypes.addAll(types);
+    public FeatureTypeBuilder() {
+        nameFactory = DefaultFactories.forBuildin(NameFactory.class);
     }
 
     /**
-     * Set parent types.
-     * Feature type will inherit all parent properties.
-     *
-     * @param types not null
+     * Resets this builder to its initial state. After invocation of this 
method,
+     * this builder is in the same state than after construction.
      */
-    public void setSuperTypes(final FeatureType... types) {
+    @Override
+    public void clear() {
+        super.clear();
+        properties.clear();
         superTypes.clear();
-        superTypes.addAll(Arrays.asList(types));
+        isAbstract       = false;
+        idPrefix         = null;
+        idDelimiter      = null;
+        idAttributes     = null;
+        defGeomAttribute = null;
     }
 
     /**
-     * Define an id operation composed of the given attribute.
-     * Generated id prefix will be the name of the featuretype+'.'
-     *
-     * @param attributeName attribute id used in the id operation
-     */
-    public void setIdOperation(final String attributeName) {
-        setIdOperation(null, "-", create(attributeName));
+     * Sets this builder state to properties inferred from the given feature 
type.
+     * This method fetches the {@code FeatureType} name, definition, 
designation, description, super-types,
+     * abstract flag, and list of properties from the given instance.
+     *
+     * <p>This method is useful when an existing instance is to be used as a 
template.</p>
+     *
+     * @param template  feature type to copy parameters from.
+     */
+    public void copy(final FeatureType template) {
+        super.copy(template);
+        setAbstract(template.isAbstract());
+        Set<? extends FeatureType> parents = template.getSuperTypes();
+        setSuperTypes(parents.toArray(new FeatureType[parents.size()]));
+        for (PropertyType pt : template.getProperties(false)) {
+            addProperty(pt);
+        }
     }
 
     /**
-     * Define an id operation composed of the given attributes.
-     * Generated id prefix will be the name of the featuretype+'.'
+     * Sets whether the feature type is abstract.
+     * If this method is not invoked, then the default value is {@code false}.
      *
-     * @param attributes attributes used in the id operation
+     * @param isAbstract whether the feature type is abstract.
      */
-    public void setIdOperation(final GenericName ... attributes) {
-        setIdOperation(null, "-", attributes);
+    public void setAbstract(final boolean isAbstract) {
+        this.isAbstract = isAbstract;
     }
 
     /**
-     * Define an id operation composed of the given attribute.
+     * Sets the parent types (or super-type) from which to inherit properties.
+     * If this method is not invoked, then the default value is to have no 
parent.
      *
-     * @param prefix generated id prefix
-     * @param attributeName attribute id used in the id operation
+     * @param parents  the parent types from which to inherit properties, or 
an empty array if none.
      */
-    public void setIdOperation(final String prefix, final String 
attributeName) {
-        setIdOperation(prefix, "-", create(attributeName));
-    }
-
-    /**
-     * Define an id operation composed of the given attributes.
-     *
-     * @param prefix generated id prefix
-     * @param attributes attributes used in the id operation
-     */
-    public void setIdOperation(final String prefix, final GenericName ... 
attributes) {
-        setIdOperation(prefix, "-", attributes);
+    public void setSuperTypes(final FeatureType... parents) {
+        ArgumentChecks.ensureNonNull("parents", parents);
+        superTypes.clear();
+        superTypes.addAll(Arrays.asList(parents));
     }
 
     /**
@@ -260,31 +178,11 @@ public class FeatureTypeBuilder {
      * @param separator generated id separator between attribute values
      * @param attributes attributes used in the id operation
      */
-    public void setIdOperation(final String prefix, final String separator, 
final GenericName ... attributes) {
-        idPrefix = prefix;
-        idSeparator = separator;
-        idAttributes = attributes;
-        //add placeholder
-        properties.put(ID_PROPERTY, null);
-    }
-
-    /**
-     * Define a default geometry link operation.
-     *
-     * @param attribute referenced attribute
-     */
-    public void setDefaultGeometryOperation(final String attribute) {
-        setDefaultGeometryOperation(create(attribute));
-    }
-
-    /**
-     * Define a default geometry link operation.
-     *
-     * @param scope referenced attribute name scope
-     * @param localPart referenced name tip
-     */
-    public void setDefaultGeometryOperation(final String scope, final String 
localPart) {
-        setDefaultGeometryOperation(create(scope,localPart));
+    public void setIdOperation(final String prefix, final String separator, 
final GenericName... attributes) {
+        idPrefix     = prefix;
+        idDelimiter  = separator;
+        idAttributes = attributes.clone();
+        properties.put(ID_PROPERTY, null);                                  // 
Add placeholder
     }
 
     /**
@@ -294,8 +192,7 @@ public class FeatureTypeBuilder {
      */
     public void setDefaultGeometryOperation(final GenericName attribute) {
         defGeomAttribute = attribute;
-        //add placeholder
-        properties.put(DEFAULT_GEOMETRY_PROPERTY, null);
+        properties.put(DEFAULT_GEOMETRY_PROPERTY, null);                    // 
Add placeholder
         properties.put(ENVELOPE_PROPERTY, null);
     }
 
@@ -309,7 +206,7 @@ public class FeatureTypeBuilder {
      * @return created property type
      */
     public <V> AttributeType<V> addProperty(final String localPart, final 
Class<V> valueClass) {
-        return addProperty(create(localPart), valueClass);
+        return addProperty(name(null, localPart), valueClass);
     }
 
     /**
@@ -323,7 +220,7 @@ public class FeatureTypeBuilder {
      * @return created property type
      */
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass) {
-        return addProperty(create(scope, localPart), valueClass);
+        return addProperty(name(scope, localPart), valueClass);
     }
 
     /**
@@ -367,7 +264,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
             final Class<V> valueClass, final CoordinateReferenceSystem crs)
     {
-        return addProperty(create(scope, localPart), valueClass, crs);
+        return addProperty(name(scope, localPart), valueClass, crs);
     }
 
     /**
@@ -397,7 +294,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
             final Class<V> valueClass, final V defaultValue)
     {
-        return addProperty(create(scope, localPart), valueClass, defaultValue, 
null);
+        return addProperty(name(scope, localPart), valueClass, defaultValue, 
null);
     }
 
     /**
@@ -415,7 +312,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart,
             final Class<V> valueClass, final V defaultValue, final 
CoordinateReferenceSystem crs)
     {
-        return addProperty(create(scope, localPart), valueClass, 1, 1, 
defaultValue, crs);
+        return addProperty(name(scope, localPart), valueClass, 1, 1, 
defaultValue, crs);
     }
 
     /**
@@ -462,7 +359,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String localPart, final 
Class<V> valueClass,
             final int minimumOccurs, final int maximumOccurs, final V 
defaultValue)
     {
-        return addProperty(create(localPart), valueClass, minimumOccurs, 
maximumOccurs, defaultValue);
+        return addProperty(name(null, localPart), valueClass, minimumOccurs, 
maximumOccurs, defaultValue);
     }
 
     /**
@@ -479,7 +376,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass,
             final int minimumOccurs, final int maximumOccurs, final V 
defaultValue)
     {
-        return addProperty(create(scope, localPart), valueClass, 
minimumOccurs, maximumOccurs, defaultValue);
+        return addProperty(name(scope, localPart), valueClass, minimumOccurs, 
maximumOccurs, defaultValue);
     }
 
     /**
@@ -497,7 +394,7 @@ public class FeatureTypeBuilder {
     public <V> AttributeType<V> addProperty(final String scope, final String 
localPart, final Class<V> valueClass,
             final int minimumOccurs, final int maximumOccurs, final V 
defaultValue, final CoordinateReferenceSystem crs)
     {
-        return addProperty(create(scope, localPart), valueClass, 
minimumOccurs, maximumOccurs, defaultValue, crs);
+        return addProperty(name(scope, localPart), valueClass, minimumOccurs, 
maximumOccurs, defaultValue, crs);
     }
 
     /**
@@ -533,14 +430,14 @@ public class FeatureTypeBuilder {
         final AttributeType<V> att;
         if (crs != null) {
             final AttributeType<CoordinateReferenceSystem> qualifier = new 
DefaultAttributeType<>(
-                    Collections.singletonMap(NAME_KEY, CRS_CHARACTERISTIC),
+                    Collections.singletonMap(DefaultFeatureType.NAME_KEY, 
CRS_CHARACTERISTIC),
                     CoordinateReferenceSystem.class, 1, 1, crs);
             att = new DefaultAttributeType<>(
-                Collections.singletonMap(NAME_KEY, name),
+                Collections.singletonMap(DefaultFeatureType.NAME_KEY, name),
                 valueClass, minimumOccurs, maximumOccurs, defaultValue, 
qualifier);
         } else {
             att = new DefaultAttributeType<>(
-                Collections.singletonMap(NAME_KEY, name),
+                Collections.singletonMap(DefaultFeatureType.NAME_KEY, name),
                 valueClass, minimumOccurs, maximumOccurs, defaultValue);
         }
         addProperty(att);
@@ -596,7 +493,7 @@ public class FeatureTypeBuilder {
     public FeatureAssociationRole addAssociation(final String scope, final 
String localPart, final FeatureType type,
             final int minimumOccurs, final int maximumOccurs)
     {
-        return addAssociation(create(scope, localPart), type,minimumOccurs, 
maximumOccurs);
+        return addAssociation(name(scope, localPart), type,minimumOccurs, 
maximumOccurs);
     }
 
     /**
@@ -612,7 +509,7 @@ public class FeatureTypeBuilder {
             final int minimumOccurs, final int maximumOccurs)
     {
         final FeatureAssociationRole role = new DefaultAssociationRole(
-                Collections.singletonMap(NAME_KEY, name), type, minimumOccurs, 
maximumOccurs);
+                Collections.singletonMap(DefaultFeatureType.NAME_KEY, name), 
type, minimumOccurs, maximumOccurs);
         addProperty(role);
         return role;
     }
@@ -681,7 +578,7 @@ public class FeatureTypeBuilder {
 
             final Operation att = FeatureOperations.compound(
                     Collections.singletonMap(AbstractOperation.NAME_KEY, 
ID_PROPERTY),
-                    idSeparator, prefix, null, properties.get(idAttributes));
+                    idDelimiter, prefix, null, properties.get(idAttributes));
             properties.put(ID_PROPERTY, att);
         }
         //build default geometry property
@@ -695,16 +592,21 @@ public class FeatureTypeBuilder {
                     Collections.singletonMap(AbstractOperation.NAME_KEY, 
DEFAULT_GEOMETRY_PROPERTY), geomAtt);
             properties.put(DEFAULT_GEOMETRY_PROPERTY, att);
 
-            // TODO
-//            final Operation boundAtt = 
FeatureOperations.bounds(Collections.singletonMap(AbstractOperation.NAME_KEY, 
ENVELOPE_PROPERTY), null, crs);
-//            properties.put(ENVELOPE_PROPERTY, boundAtt);
+            final Operation boundAtt;
+            try {
+                boundAtt = 
FeatureOperations.envelope(Collections.singletonMap(AbstractOperation.NAME_KEY, 
ENVELOPE_PROPERTY),
+                        crs, properties.values().toArray(new 
PropertyType[properties.size()]));
+            } catch (FactoryException e) {
+                throw new IllegalStateException(e);
+            }
+            properties.put(ENVELOPE_PROPERTY, boundAtt);
 
         }
 
         verifyOperations();
 
         return new DefaultFeatureType(
-                parameters,
+                identification,
                 isAbstract,
                 superTypes.toArray(new FeatureType[superTypes.size()]),
                 properties.values().toArray(new 
PropertyType[properties.size()]));
@@ -736,21 +638,17 @@ public class FeatureTypeBuilder {
     // Name utils 
//////////////////////////////////////////////////////////////
     
////////////////////////////////////////////////////////////////////////////
 
-
-    private static GenericName create(final String local) {
-        return create(null,local);
-    }
-
     /**
      *
      * @param parsedNames mandatory
      * @return GenericName
      */
-    private static GenericName create(final String scope, final String 
localPart) {
+    @Override
+    final GenericName name(final String scope, final String localPart) {
         if (scope == null) {
-            return 
DefaultFactories.forBuildin(NameFactory.class).createGenericName(null, 
localPart);
+            return nameFactory.createLocalName(null, localPart);
         } else {
-            return 
DefaultFactories.forBuildin(NameFactory.class).createGenericName(null, scope, 
localPart);
+            return nameFactory.createGenericName(null, scope, localPart);
         }
     }
 
@@ -765,7 +663,7 @@ public class FeatureTypeBuilder {
      * @param candidate String to convert to a geoneric name
      * @return Name
      */
-    private static GenericName valueOf(final String candidate) {
+    private GenericName valueOf(final String candidate) {
 
         if (candidate.startsWith("{")) {
             //name is in extended form
@@ -775,16 +673,16 @@ public class FeatureTypeBuilder {
         int index = candidate.lastIndexOf(':');
 
         if (index <= 0) {
-            return create(null, candidate);
+            return name(null, candidate);
         } else {
             final String uri = candidate.substring(0,index);
             final String name = 
candidate.substring(index+1,candidate.length());
-            return create(uri, name);
+            return name(uri, name);
         }
 
     }
 
-    private static GenericName toSessionNamespaceFromExtended(final String 
candidate) {
+    private GenericName toSessionNamespaceFromExtended(final String candidate) 
{
         final int index = candidate.indexOf('}');
 
         if (index < 0) throw new IllegalArgumentException("Invalide extended 
form : "+ candidate);
@@ -792,7 +690,7 @@ public class FeatureTypeBuilder {
         final String uri = candidate.substring(1, index);
         final String name = candidate.substring(index+1, candidate.length());
 
-        return create(uri, name);
+        return name(uri, name);
     }
 
     private static String toExpandedString(final GenericName name) {

Modified: 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/NameConvention.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/NameConvention.java?rev=1739820&r1=1739819&r2=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/NameConvention.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/NameConvention.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -165,7 +165,7 @@ public final class NameConvention extend
         NAMESPACE                     = factory.createGenericName(null, 
"Apache", Constants.SIS);
         NameSpace ns                  = factory.createNameSpace(NAMESPACE, 
null);
         ID_PROPERTY                   = factory.createLocalName(ns, 
"@identifier");
-        DEFAULT_GEOMETRY_PROPERTY     = factory.createLocalName(ns, 
"@geometry");
+        DEFAULT_GEOMETRY_PROPERTY     = factory.createLocalName(ns, 
"@defaultGeometry");
         ENVELOPE_PROPERTY             = factory.createLocalName(ns, 
"@envelope");
         CRS_CHARACTERISTIC            = factory.createLocalName(ns, "@crs");
         MAXIMAL_LENGTH_CHARACTERISTIC = factory.createLocalName(ns, 
"@maximalLength");

Modified: 
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/FeatureTypeBuilderTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/FeatureTypeBuilderTest.java?rev=1739820&r1=1739819&r2=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/FeatureTypeBuilderTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/internal/feature/FeatureTypeBuilderTest.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -16,18 +16,22 @@
  */
 package org.apache.sis.internal.feature;
 
+import java.util.List;
+import java.util.ArrayList;
 import com.esri.core.geometry.Geometry;
 import com.esri.core.geometry.Point;
-import java.util.ArrayList;
-import java.util.List;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
 import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+// Branch-dependent imports
 import org.opengis.feature.AttributeType;
 import org.opengis.feature.FeatureType;
 import org.opengis.feature.PropertyType;
 
+
 /**
  * Tests {@link FeatureTypeBuilder}.
  *
@@ -36,8 +40,7 @@ import org.opengis.feature.PropertyType;
  * @version 0.7
  * @module
  */
-public class FeatureTypeBuilderTest extends TestCase {
-
+public final strictfp class FeatureTypeBuilderTest extends TestCase {
     /**
      * Test a builder with the minimum number of parameters.
      */
@@ -46,14 +49,14 @@ public class FeatureTypeBuilderTest exte
         final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
 
         //check at least name must be set
-        try{
+        try {
             ftb.build();
             fail("Builder should have failed if there is not at least a name 
set.");
-        }catch(IllegalArgumentException ex){
+        } catch (IllegalArgumentException ex) {
             //ok
         }
 
-        ftb.reset();
+        ftb.clear();
         ftb.setName("scope","test");
         FeatureType type = ftb.build();
 
@@ -89,7 +92,7 @@ public class FeatureTypeBuilderTest exte
         assertTrue(type.isAbstract());
         assertEquals(4, type.getProperties(true).size());
 
-        final List<PropertyType> properties = new 
ArrayList(type.getProperties(true));
+        final List<PropertyType> properties = new 
ArrayList<>(type.getProperties(true));
         assertEquals("name",    properties.get(0).getName().toString());
         assertEquals("age",     properties.get(1).getName().toString());
         assertEquals("location",properties.get(2).getName().toString());
@@ -148,7 +151,7 @@ public class FeatureTypeBuilderTest exte
         assertTrue(type.isAbstract());
         assertEquals(4, type.getProperties(true).size());
 
-        final List<PropertyType> properties = new 
ArrayList(type.getProperties(true));
+        final List<PropertyType> properties = new 
ArrayList<>(type.getProperties(true));
         assertEquals("name",    properties.get(0).getName().toString());
         assertEquals("age",     properties.get(1).getName().toString());
         assertEquals("location",properties.get(2).getName().toString());
@@ -193,7 +196,7 @@ public class FeatureTypeBuilderTest exte
         ftb.addProperty("score", Double.class, 5, 50, 10.0);
 
         FeatureType type = ftb.build();
-        ftb.reset();
+        ftb.clear();
         ftb.setName("scope","test");
         type = ftb.build();
 
@@ -211,8 +214,8 @@ public class FeatureTypeBuilderTest exte
     public void testConventionProperties() {
         final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
         ftb.setName("scope","test");
-        ftb.setIdOperation("pref.", "name");
-        ftb.setDefaultGeometryOperation("shape");
+        ftb.setIdOperation("pref.", "-", ftb.name(null, "name"));
+        ftb.setDefaultGeometryOperation(ftb.name(null, "shape"));
         ftb.addProperty("name", String.class);
         ftb.addProperty("shape", Geometry.class, 
CommonCRS.WGS84.normalizedGeographic());
 
@@ -221,7 +224,7 @@ public class FeatureTypeBuilderTest exte
         assertFalse(type.isAbstract());
         assertEquals(5, type.getProperties(true).size());
 
-        final List<PropertyType> properties = new 
ArrayList(type.getProperties(true));
+        final List<PropertyType> properties = new 
ArrayList<>(type.getProperties(true));
         assertEquals(NameConvention.ID_PROPERTY, properties.get(0).getName());
         assertEquals(NameConvention.DEFAULT_GEOMETRY_PROPERTY, 
properties.get(1).getName());
         assertEquals(NameConvention.ENVELOPE_PROPERTY, 
properties.get(2).getName());

Modified: 
sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java?rev=1739820&r1=1739819&r2=1739820&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
 [UTF-8] Mon Apr 18 20:47:50 2016
@@ -53,7 +53,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String ATT_GPX_VERSION = "version";
     /** used in version : 1.0 and 1.1 */
-    public static final String ATT_GPX_CREATOR = "creator";             
+    public static final String ATT_GPX_CREATOR = "creator";
 
     /**
      * Attributs used a bit everywhere.
@@ -75,7 +75,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String TAG_TYPE = "type";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_NUMBER = "number";                   
+    public static final String TAG_NUMBER = "number";
 
     /**
      * Metadata tag.
@@ -85,7 +85,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String TAG_METADATA_TIME = "time";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_METADATA_KEYWORDS = "keywords";      
+    public static final String TAG_METADATA_KEYWORDS = "keywords";
 
     /**
      * Person tag.
@@ -93,7 +93,7 @@ public final class GPXConstants extends
     /** used in version : 1.0(as attribut) and 1.1(as tag) */
     public static final String TAG_AUTHOR = "author";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_AUTHOR_EMAIL = "email";              
+    public static final String TAG_AUTHOR_EMAIL = "email";
 
     /**
      * CopyRight tag.
@@ -105,7 +105,7 @@ public final class GPXConstants extends
     /** used in version : 1.1 */
     public static final String TAG_COPYRIGHT_LICENSE = "license";
     /** used in version : 1.1 */
-    public static final String ATT_COPYRIGHT_AUTHOR = "author";         
+    public static final String ATT_COPYRIGHT_AUTHOR = "author";
 
     /**
      * Bounds tag.
@@ -119,7 +119,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String ATT_BOUNDS_MAXLAT = "maxlat";
     /** used in version : 1.0 and 1.1 */
-    public static final String ATT_BOUNDS_MAXLON = "maxlon";            
+    public static final String ATT_BOUNDS_MAXLON = "maxlon";
 
     /**
      * Link tag.
@@ -129,7 +129,7 @@ public final class GPXConstants extends
     /** used in version : 1.1 */
     public static final String TAG_LINK_TYPE = "type";
     /** used in version : 1.1 */
-    public static final String ATT_LINK_HREF = "href";                  
+    public static final String ATT_LINK_HREF = "href";
 
     /**
      * WPT tag.
@@ -163,7 +163,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String TAG_WPT_AGEOFGPSDATA = "ageofdgpsdata";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_WPT_DGPSID = "dgpsid";               
+    public static final String TAG_WPT_DGPSID = "dgpsid";
 
     /**
      * RTE tag.
@@ -171,7 +171,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String TAG_RTE = "rte";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_RTE_RTEPT = "rtept";                 
+    public static final String TAG_RTE_RTEPT = "rtept";
 
     /**
      * TRK tag.
@@ -181,7 +181,7 @@ public final class GPXConstants extends
     /** used in version : 1.0 and 1.1 */
     public static final String TAG_TRK_SEG = "trkseg";
     /** used in version : 1.0 and 1.1 */
-    public static final String TAG_TRK_SEG_PT = "trkpt";                
+    public static final String TAG_TRK_SEG_PT = "trkpt";
 
     /**
      * Coordinate reference system used by gpx files.
@@ -227,10 +227,10 @@ public final class GPXConstants extends
         final AttributeTypeBuilder atb = new AttributeTypeBuilder();
 
         //-------------------- GENERIC GPX ENTITY 
------------------------------
-        final AttributeType attIndex = 
createAttribute("index",Integer.class,1,1,null);
+        final AttributeType<Integer> attIndex = createAttribute("index", 
Integer.class, 1, 1);
         final String geomName = "geometry";
 
-        ftb.reset();
+        ftb.clear();
         ftb.setName(GPX_NAMESPACE, "GPXEntity");
         ftb.setAbstract(true);
         ftb.addProperty(attIndex);
@@ -264,26 +264,26 @@ public final class GPXConstants extends
         atb.setMinimumOccurs(1);
         atb.setMaximumOccurs(1);
         final AttributeType attPointGeometry =    atb.build();
-        final AttributeType attWptEle =           createAttribute(TAG_WPT_ELE, 
           Double.class,0,1,null);
-        final AttributeType attWptTime =          
createAttribute(TAG_WPT_TIME,           Temporal.class,0,1,null);
-        final AttributeType attWptMagvar =        
createAttribute(TAG_WPT_MAGVAR,         Double.class,0,1,null);
-        final AttributeType attWptGeoHeight =     
createAttribute(TAG_WPT_GEOIHEIGHT,     Double.class,0,1,null);
-        final AttributeType attName =             createAttribute(TAG_NAME,    
           String.class,0,1,null);
-        final AttributeType attCmt =              createAttribute(TAG_CMT,     
           String.class,0,1,null);
-        final AttributeType attDesc =             createAttribute(TAG_DESC,    
           String.class,0,1,null);
-        final AttributeType attSrc =              createAttribute(TAG_SRC,     
           String.class,0,1,null);
-        final AttributeType attLink =             createAttribute(TAG_LINK,    
           URI.class,0,Integer.MAX_VALUE,null);
-        final AttributeType attWptSym =           createAttribute(TAG_WPT_SYM, 
           String.class,0,1,null);
-        final AttributeType attType =             createAttribute(TAG_TYPE,    
           String.class,0,1,null);
-        final AttributeType attWptFix =           createAttribute(TAG_WPT_FIX, 
           String.class,0,1,null);
-        final AttributeType attWptSat =           createAttribute(TAG_WPT_SAT, 
           Integer.class,0,1,null);
-        final AttributeType attWptHdop =          
createAttribute(TAG_WPT_HDOP,           Double.class,0,1,null);
-        final AttributeType attWptVdop =          
createAttribute(TAG_WPT_VDOP,           Double.class,0,1,null);
-        final AttributeType attWptPdop =          
createAttribute(TAG_WPT_PDOP,           Double.class,0,1,null);
-        final AttributeType attWptAgeofGpsData =  
createAttribute(TAG_WPT_AGEOFGPSDATA,   Double.class,0,1,null);
-        final AttributeType attWptDgpsid =        
createAttribute(TAG_WPT_DGPSID,         Integer.class,0,1,null);
+        final AttributeType attWptEle =           createAttribute(TAG_WPT_ELE, 
           Double.class);
+        final AttributeType attWptTime =          
createAttribute(TAG_WPT_TIME,           Temporal.class);
+        final AttributeType attWptMagvar =        
createAttribute(TAG_WPT_MAGVAR,         Double.class);
+        final AttributeType attWptGeoHeight =     
createAttribute(TAG_WPT_GEOIHEIGHT,     Double.class);
+        final AttributeType attName =             createAttribute(TAG_NAME,    
           String.class);
+        final AttributeType attCmt =              createAttribute(TAG_CMT,     
           String.class);
+        final AttributeType attDesc =             createAttribute(TAG_DESC,    
           String.class);
+        final AttributeType attSrc =              createAttribute(TAG_SRC,     
           String.class);
+        final AttributeType attLink =             createAttribute(TAG_LINK,    
           URI.class, 0, Integer.MAX_VALUE);
+        final AttributeType attWptSym =           createAttribute(TAG_WPT_SYM, 
           String.class);
+        final AttributeType attType =             createAttribute(TAG_TYPE,    
           String.class);
+        final AttributeType attWptFix =           createAttribute(TAG_WPT_FIX, 
           String.class);
+        final AttributeType attWptSat =           createAttribute(TAG_WPT_SAT, 
           Integer.class);
+        final AttributeType attWptHdop =          
createAttribute(TAG_WPT_HDOP,           Double.class);
+        final AttributeType attWptVdop =          
createAttribute(TAG_WPT_VDOP,           Double.class);
+        final AttributeType attWptPdop =          
createAttribute(TAG_WPT_PDOP,           Double.class);
+        final AttributeType attWptAgeofGpsData =  
createAttribute(TAG_WPT_AGEOFGPSDATA,   Double.class);
+        final AttributeType attWptDgpsid =        
createAttribute(TAG_WPT_DGPSID,         Integer.class);
 
-        ftb.reset();
+        ftb.clear();
         ftb.setName(GPX_NAMESPACE, "WayPoint");
         ftb.setSuperTypes(TYPE_GPX_ENTITY);
         ftb.addProperty(attIndex);
@@ -320,9 +320,9 @@ public final class GPXConstants extends
         //<type> xsd:string </type> [0..1] ?
         //<extensions> extensionsType </extensions> [0..1] ?
         //<rtept> wptType </rtept> [0..*] ?
-        final AttributeType attNumber          = createAttribute(TAG_NUMBER,   
 Integer.class,0,1,null);
+        final AttributeType<Integer> attNumber = createAttribute(TAG_NUMBER, 
Integer.class);
 
-        ftb.reset();
+        ftb.clear();
         ftb.setName(GPX_NAMESPACE, "Route");
         ftb.setSuperTypes(TYPE_GPX_ENTITY);
         ftb.addProperty(attIndex);
@@ -343,7 +343,7 @@ public final class GPXConstants extends
         //------------------- TRACK SEGMENT TYPE 
-------------------------------
         //<trkpt> wptType </trkpt> [0..*] ?
         //<extensions> extensionsType </extensions> [0..1] ?
-        ftb.reset();
+        ftb.clear();
         ftb.setName(GPX_NAMESPACE, "TrackSegment");
         ftb.addProperty(attIndex);
         final FeatureAssociationRole attTrackPoints = 
ftb.addAssociation(createName(TAG_TRK_SEG_PT),TYPE_WAYPOINT,0,Integer.MAX_VALUE);
@@ -362,7 +362,7 @@ public final class GPXConstants extends
         //<type> xsd:string </type> [0..1] ?
         //<extensions> extensionsType </extensions> [0..1] ?
         //<trkseg> trksegType </trkseg> [0..*] ?
-        ftb.reset();
+        ftb.clear();
         ftb.setName(GPX_NAMESPACE, "Track");
         ftb.setSuperTypes(TYPE_GPX_ENTITY);
         ftb.addProperty(attIndex);
@@ -373,7 +373,7 @@ public final class GPXConstants extends
         ftb.addProperty(attLink);
         ftb.addProperty(attNumber);
         ftb.addProperty(attType);
-        final FeatureAssociationRole attTrackSegments = 
ftb.addAssociation(createName(TAG_TRK_SEG),TYPE_TRACK_SEGMENT,0,Integer.MAX_VALUE);
+        final FeatureAssociationRole attTrackSegments = 
ftb.addAssociation(createName(TAG_TRK_SEG), TYPE_TRACK_SEGMENT, 0, 
Integer.MAX_VALUE);
         final Operation attTrackGeometry = new 
GroupPolylinesOperation(createName(geomName),attTrackSegments.getName(), 
attTrackSegGeometry.getName());
         ftb.addProperty(attTrackGeometry);
         ftb.setDefaultGeometryOperation(attTrackGeometry.getName());
@@ -384,9 +384,13 @@ public final class GPXConstants extends
     /**
      * Shortcut method to create attribute type.
      */
-    private static AttributeType createAttribute(String name, Class 
valueClass, int min, int max, Object defaultValue) {
-        return new 
DefaultAttributeType(Collections.singletonMap(AbstractIdentifiedType.NAME_KEY,
-                createName(name)), valueClass, min, max, defaultValue);
+    private static <V> AttributeType<V> createAttribute(String name, Class<V> 
valueClass, int min, int max) {
+        return new 
DefaultAttributeType<>(Collections.singletonMap(AbstractIdentifiedType.NAME_KEY,
+                createName(name)), valueClass, min, max, null);
+    }
+
+    private static <V> AttributeType<V> createAttribute(String name, Class<V> 
valueClass) {
+        return createAttribute(name, valueClass, 0, 1);
     }
 
     /**
@@ -394,9 +398,9 @@ public final class GPXConstants extends
      */
     private static GenericName createName(String localPart) {
         final NameFactory factory = 
DefaultFactories.forBuildin(NameFactory.class);
-        return factory.createGenericName(null, GPX_NAMESPACE,  localPart);
+        return factory.createGenericName(null, GPX_NAMESPACE, localPart);
     }
 
-    private GPXConstants(){};
-
+    private GPXConstants() {
+    };
 }


Reply via email to