@Test(expected = IllegalStateException.class) public void buildFeature_noLocationSet_throwsIllegalStateException() throws Exception { ComplexFeatureBuilder builder = new ComplexFeatureBuilder(FakeTypes.Mine.MINETYPE_TYPE); try { builder.buildFeature("id"); } catch (IllegalStateException ise) { ExceptionChecker.assertExceptionMessage( ise, "Failed to build feature 'urn:org:example:MineType'; its property 'urn:org:example:mineName' requires at least 1 occurrence(s) but number of occurrences was 0."); } }
@Override public Feature buildFeature(String id) { id = id == null ? FeatureBuilder.createDefaultFeatureId() : id; for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); if (!values.containsKey(name)) { values.put(name, new ArrayList<Property>()); } List<Property> properties = values.get(name); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (numberOfProperties < minOccurs) { if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { do { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); properties.add(nullProperty); } while (++numberOfProperties < minOccurs); } else { throw new IllegalStateException( String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties)); } } } Collection<Property> properties = new ArrayList<Property>(); for (Name key : values.keySet()) { properties.addAll(values.get(key)); } this.values.clear(); if (ad != null) { return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id); } }
ComplexFeatureBuilder extends FeatureBuilder<FeatureType, Feature> { @Override public Feature buildFeature(String id) { id = id == null ? FeatureBuilder.createDefaultFeatureId() : id; for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); if (!values.containsKey(name)) { values.put(name, new ArrayList<Property>()); } List<Property> properties = values.get(name); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (numberOfProperties < minOccurs) { if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { do { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); properties.add(nullProperty); } while (++numberOfProperties < minOccurs); } else { throw new IllegalStateException( String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties)); } } } Collection<Property> properties = new ArrayList<Property>(); for (Name key : values.keySet()) { properties.addAll(values.get(key)); } this.values.clear(); if (ad != null) { return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id); } } }
ComplexFeatureBuilder extends FeatureBuilder<FeatureType, Feature> { @Override public Feature buildFeature(String id) { id = id == null ? FeatureBuilder.createDefaultFeatureId() : id; for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); if (!values.containsKey(name)) { values.put(name, new ArrayList<Property>()); } List<Property> properties = values.get(name); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (numberOfProperties < minOccurs) { if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { do { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); properties.add(nullProperty); } while (++numberOfProperties < minOccurs); } else { throw new IllegalStateException( String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties)); } } } Collection<Property> properties = new ArrayList<Property>(); for (Name key : values.keySet()) { properties.addAll(values.get(key)); } this.values.clear(); if (ad != null) { return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id); } } ComplexFeatureBuilder(FeatureType featureType); protected  ComplexFeatureBuilder(FeatureType featureType, FeatureFactory factory);  ComplexFeatureBuilder(AttributeDescriptor ad); protected  ComplexFeatureBuilder(AttributeDescriptor ad, FeatureFactory factory); }
ComplexFeatureBuilder extends FeatureBuilder<FeatureType, Feature> { @Override public Feature buildFeature(String id) { id = id == null ? FeatureBuilder.createDefaultFeatureId() : id; for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); if (!values.containsKey(name)) { values.put(name, new ArrayList<Property>()); } List<Property> properties = values.get(name); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (numberOfProperties < minOccurs) { if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { do { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); properties.add(nullProperty); } while (++numberOfProperties < minOccurs); } else { throw new IllegalStateException( String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties)); } } } Collection<Property> properties = new ArrayList<Property>(); for (Name key : values.keySet()) { properties.addAll(values.get(key)); } this.values.clear(); if (ad != null) { return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id); } } ComplexFeatureBuilder(FeatureType featureType); protected  ComplexFeatureBuilder(FeatureType featureType, FeatureFactory factory);  ComplexFeatureBuilder(AttributeDescriptor ad); protected  ComplexFeatureBuilder(AttributeDescriptor ad, FeatureFactory factory); @Override Feature buildFeature(String id); void append(Name name, Property value); }
ComplexFeatureBuilder extends FeatureBuilder<FeatureType, Feature> { @Override public Feature buildFeature(String id) { id = id == null ? FeatureBuilder.createDefaultFeatureId() : id; for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName(); if (!values.containsKey(name)) { values.put(name, new ArrayList<Property>()); } List<Property> properties = values.get(name); int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size(); if (numberOfProperties < minOccurs) { if (propertyDescriptor.isNillable() && AttributeDescriptor.class.isAssignableFrom( propertyDescriptor.getClass())) { do { Property nullProperty = new AttributeImpl( propertyDescriptor.getType().getBinding().cast(null), (AttributeDescriptor) propertyDescriptor, null); properties.add(nullProperty); } while (++numberOfProperties < minOccurs); } else { throw new IllegalStateException( String.format( "Failed to build feature '%s'; its property '%s' requires at least %s occurrence(s) but number of occurrences was %s.", featureType.getName(), name, minOccurs, numberOfProperties)); } } } Collection<Property> properties = new ArrayList<Property>(); for (Name key : values.keySet()) { properties.addAll(values.get(key)); } this.values.clear(); if (ad != null) { return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id); } } ComplexFeatureBuilder(FeatureType featureType); protected  ComplexFeatureBuilder(FeatureType featureType, FeatureFactory factory);  ComplexFeatureBuilder(AttributeDescriptor ad); protected  ComplexFeatureBuilder(AttributeDescriptor ad, FeatureFactory factory); @Override Feature buildFeature(String id); void append(Name name, Property value);  }