nus-yam/ex-repair huggingface dataset:
Program: 92044
Project: 92044
Buggy source:
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws IllegalArgumentException If the given argument is not the name of an attribute orfeature association of this feature.
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) final Property createProperty(final String name) throws IllegalArgumentException {
  final PropertyType pt=type.getProperty(name);
  if (pt instanceof AttributeType<?>) {
    return ((AttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof FeatureAssociationRole) {
    return ((FeatureAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws PropertyNotFoundException if the given argument is not the name of an attribute orfeature association of this feature.
 */
final Property createProperty(final String name) throws PropertyNotFoundException {
  final PropertyType pt=type.getProperty(name);
  if (pt instanceof AttributeType<?>) {
    return ((AttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof FeatureAssociationRole) {
    return ((FeatureAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}
Program: 92045
Project: 92045
Buggy source:
/** 
 * Returns the exception for a property value (usually a feature) of wrong type.
 */
private static IllegalArgumentException illegalPropertyType(final GenericName name,final Object value){
  return new IllegalArgumentException(Errors.format(Errors.Keys.IllegalPropertyClass_2,name,value));
}

Fixed version (ground truth):
/** 
 * Returns the exception for a property value (usually a feature) of wrong type.
 */
private static InvalidPropertyValueException illegalPropertyType(final GenericName name,final Object value){
  return new InvalidPropertyValueException(Errors.format(Errors.Keys.IllegalPropertyClass_2,name,value));
}
Program: 92046
Project: 92046
Buggy source:
/** 
 * Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then an   {@link IllegalArgumentException}will be thrown with an error message formatted using the name of expected and given types.
 * @param index Index of the expected attribute type.
 * @param type  The actual attribute type.
 */
final void verifyAttributeType(final int index,final AttributeType<?> type){
  final AttributeType<?> expected=types.characterizedBy[index];
  if (!expected.equals(type)) {
    final GenericName en=expected.getName();
    final GenericName an=type.getName();
    throw new IllegalArgumentException(String.valueOf(en).equals(String.valueOf(an)) ? Errors.format(Errors.Keys.MismatchedPropertyType_1,en) : Errors.format(Errors.Keys.CanNotAssign_2,en.push(source.getName()),an));
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then an   {@link IllegalArgumentException}will be thrown with an error message formatted using the name of expected and given types.
 * @param index Index of the expected attribute type.
 * @param type  The actual attribute type.
 */
final void verifyAttributeType(final int index,final AttributeType<?> type){
  final AttributeType<?> expected=types.characterizedBy[index];
  if (!expected.equals(type)) {
    final GenericName en=expected.getName();
    final GenericName an=type.getName();
    throw new InvalidPropertyValueException(String.valueOf(en).equals(String.valueOf(an)) ? Errors.format(Errors.Keys.MismatchedPropertyType_1,en) : Errors.format(Errors.Keys.CanNotAssign_2,en.push(source.getName()),an));
  }
}
Program: 92047
Project: 92047
Buggy source:
/** 
 * Returns the index for the characteristic of the given name.
 * @param key The name for which to get the characteristic index.
 * @return The index for the characteristic of the given name.
 * @throws IllegalArgumentException if the given key is not the name of a characteristic in this map.
 */
private int indexOf(final String key){
  ArgumentChecks.ensureNonNull("String_Node_Str",key);
  final Integer index=types.indices.get(key);
  if (index == null) {
    throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,source.getName(),key));
  }
  return index;
}

Fixed version (ground truth):
/** 
 * Returns the index for the characteristic of the given name.
 * @param key The name for which to get the characteristic index.
 * @return The index for the characteristic of the given name.
 * @throws PropertyNotFoundException if the given key is not the name of a characteristic in this map.
 */
private int indexOf(final String key){
  ArgumentChecks.ensureNonNull("String_Node_Str",key);
  final Integer index=types.indices.get(key);
  if (index == null) {
    throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,source.getName(),key));
  }
  return index;
}
Program: 92048
Project: 92048
Buggy source:
/** 
 * Returns the attribute, operation or association role for the given name.
 * @param name The name of the property to search.
 * @return The property for the given name, or {@code null} if none.
 * @throws IllegalArgumentException If the given argument is not a property name of this feature.
 * @see AbstractFeature#getProperty(String)
 */
@Override public PropertyType getProperty(final String name) throws IllegalArgumentException {
  final PropertyType pt=byName.get(name);
  if (pt != null) {
    return pt;
  }
  throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}

Fixed version (ground truth):
/** 
 * Returns the attribute, operation or association role for the given name.
 * @param name The name of the property to search.
 * @return The property for the given name, or {@code null} if none.
 * @throws PropertyNotFoundException If the given argument is not a property name of this feature.
 * @see AbstractFeature#getProperty(String)
 */
@Override public PropertyType getProperty(final String name) throws PropertyNotFoundException {
  final PropertyType pt=byName.get(name);
  if (pt != null) {
    return pt;
  }
  throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}
Program: 92049
Project: 92049
Buggy source:
/** 
 * Creates a new feature instance of this type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} and {@code Feature} to {@link Object} in the Java language,then this method is equivalent to  {@link Class#newInstance()}.</div>
 * @return A new feature instance.
 * @throws IllegalStateException if this feature type {@linkplain #isAbstract() is abstract}.
 */
@Override public Feature newInstance() throws IllegalStateException {
  if (isAbstract) {
    throw new IllegalStateException(Errors.format(Errors.Keys.AbstractType_1,getName()));
  }
  return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}

Fixed version (ground truth):
/** 
 * Creates a new feature instance of this type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} and {@code Feature} to {@link Object} in the Java language,then this method is equivalent to  {@link Class#newInstance()}.</div>
 * @return A new feature instance.
 * @throws FeatureInstantiationException if this feature type {@linkplain #isAbstract() is abstract}.
 */
@Override public Feature newInstance() throws FeatureInstantiationException {
  if (isAbstract) {
    throw new FeatureInstantiationException(Errors.format(Errors.Keys.AbstractType_1,getName()));
  }
  return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}
Program: 92050
Project: 92050
Buggy source:
/** 
 * Returns   {@code true} if this type is same or a super-type of the given type.The check is based mainly on the feature type  {@linkplain #getName() name}, which should be unique. However as a safety, this method also checks that all properties in this feature type is assignable from a property of the same name in the given type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} in the Java language, then this method is equivalentto  {@link Class#isAssignableFrom(Class)}.</div>
 * @param type The type to be checked.
 * @return {@code true} if instances of the given type can be assigned to association of this type.
 */
@Override public boolean isAssignableFrom(final FeatureType type){
  if (type == this) {
    return true;
  }
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  if (!maybeAssignableFrom(this,type)) {
    return false;
  }
  for (  final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
    final PropertyType other;
    try {
      other=type.getProperty(entry.getKey());
    }
 catch (    IllegalArgumentException e) {
      return false;
    }
    if (!isAssignableIgnoreName(entry.getValue(),other)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if this type is same or a super-type of the given type.The check is based mainly on the feature type  {@linkplain #getName() name}, which should be unique. However as a safety, this method also checks that all properties in this feature type is assignable from a property of the same name in the given type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} in the Java language, then this method is equivalentto  {@link Class#isAssignableFrom(Class)}.</div>
 * @param type The type to be checked.
 * @return {@code true} if instances of the given type can be assigned to association of this type.
 */
@Override public boolean isAssignableFrom(final FeatureType type){
  if (type == this) {
    return true;
  }
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  if (!maybeAssignableFrom(this,type)) {
    return false;
  }
  for (  final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
    final PropertyType other;
    try {
      other=type.getProperty(entry.getKey());
    }
 catch (    PropertyNotFoundException e) {
      return false;
    }
    if (!isAssignableIgnoreName(entry.getValue(),other)) {
      return false;
    }
  }
  return true;
}
Program: 92051
Project: 92051
Buggy source:
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof DenseFeature) {
    final DenseFeature that=(DenseFeature)obj;
    return type.equals(that.type) && Arrays.equals(properties,that.properties);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof DenseFeature) {
    final DenseFeature that=(DenseFeature)obj;
    if (type.equals(that.type)) {
      final boolean asProperties=(properties instanceof Property[]);
      if (asProperties != (that.properties instanceof Property[])) {
        if (asProperties) {
          that.wrapValuesInProperties();
        }
 else {
          wrapValuesInProperties();
        }
      }
      return Arrays.equals(properties,that.properties);
    }
  }
  return false;
}
Program: 92052
Project: 92052
Buggy source:
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof SparseFeature) {
    final SparseFeature that=(SparseFeature)obj;
    return type.equals(that.type) && properties.equals(that.properties);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof SparseFeature) {
    final SparseFeature that=(SparseFeature)obj;
    if (type.equals(that.type)) {
      final boolean asProperties=(valuesKind == PROPERTIES);
      if (asProperties != (that.valuesKind == PROPERTIES)) {
        if (asProperties) {
          that.requireMapOfProperties();
        }
 else {
          requireMapOfProperties();
        }
      }
      return properties.equals(that.properties);
    }
  }
  return false;
}
Program: 92053
Project: 92053
Buggy source:
/** 
 * Returns the text in a   {@code <gco:CharacterString>} element, or {@code null} if none.
 * @return The text, or {@code null}.
 */
@XmlElement(name="String_Node_Str") public final String getCharacterString(){
  if (type == 0) {
    final CharSequence text=this.text;
    if (text != null && !(text instanceof Anchor)) {
      return text.toString();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the text in a   {@code <gco:CharacterString>} element, or {@code null} if none.
 * @return The text, or {@code null}.
 */
@XmlElement(name="String_Node_Str") public final String getCharacterString(){
  if (type == 0) {
    final CharSequence text=this.text;
    if (text != null && !(text instanceof Anchor)) {
      if (text instanceof InternationalString) {
        final Context context=Context.current();
        if (context != null) {
          return ((InternationalString)text).toString(context.getLocale());
        }
      }
      return text.toString();
    }
  }
  return null;
}
Program: 92054
Project: 92054
Buggy source:
/** 
 * Constructs a   {@linkplain TextGroup text group} from the given {@link InternationalString}if it contains at least one non-root locale. Otherwise returns   {@code null}, meaning that the simpler   {@link GO_CharacterString} construct should be used instead.
 * @param context The current (un)marshalling context, or {@code null} if none.
 * @param text    An international string which could have several translationsembedded for the same text.
 * @return A {@code PT_FreeText} instance if the given text has several translations,or  {@code null} otherwise.
 */
@SuppressWarnings("String_Node_Str") public static PT_FreeText create(final Context context,final InternationalString text){
  if (text instanceof DefaultInternationalString) {
    final DefaultInternationalString df=(DefaultInternationalString)text;
    final Set<Locale> locales=df.getLocales();
    final TextGroup[] textGroup=new TextGroup[locales.size()];
    int n=0;
    for (    final Locale locale : locales) {
      if (locale != null && !locale.equals(Locale.ROOT)) {
        textGroup[n++]=new TextGroup(locale,text.toString(locale));
      }
    }
    if (n != 0) {
      return new PT_FreeText(df.toString(context != null ? context.getLocale() : null),ArraysExt.resize(textGroup,n));
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Constructs a   {@linkplain TextGroup text group} from the given {@link InternationalString}if it contains at least one non-root locale. Otherwise returns   {@code null}, meaning that the simpler   {@link GO_CharacterString} construct should be used instead.
 * @param text An international string which could have several translations embedded for the same text.
 * @return A {@code PT_FreeText} instance if the given text has several translations, or {@code null} otherwise.
 */
public static PT_FreeText create(final InternationalString text){
  if (text instanceof DefaultInternationalString) {
    final DefaultInternationalString df=(DefaultInternationalString)text;
    final Set<Locale> locales=df.getLocales();
    final TextGroup[] textGroup=new TextGroup[locales.size()];
    int n=0;
    for (    final Locale locale : locales) {
      if (locale != null && !locale.equals(Locale.ROOT)) {
        textGroup[n++]=new TextGroup(locale,text.toString(locale));
      }
    }
    if (n != 0) {
      final Context context=Context.current();
      return new PT_FreeText(df.toString(context != null ? context.getLocale() : null),ArraysExt.resize(textGroup,n));
    }
  }
  return null;
}
Program: 92055
Project: 92055
Buggy source:
/** 
 * Returns the content of this   {@code <gco:CharacterString>} as an {@code InternationalString}.
 */
@Override public CharSequence toCharSequence(){
  String defaultValue=toString();
  if (defaultValue != null && contains(defaultValue)) {
    defaultValue=null;
  }
  DefaultInternationalString i18n=null;
  final TextGroup[] textGroup=this.textGroup;
  if (textGroup != null) {
    for (    final TextGroup group : textGroup) {
      if (group != null) {
        final LocalisedCharacterString[] localised=group.localized;
        if (localised != null) {
          for (          final LocalisedCharacterString text : localised) {
            if (text != null) {
              if (i18n == null) {
                i18n=new DefaultInternationalString(defaultValue);
              }
              i18n.add(text.locale,text.text);
            }
          }
        }
      }
    }
  }
  if (i18n == null && defaultValue != null) {
    return new SimpleInternationalString(defaultValue);
  }
  return i18n;
}

Fixed version (ground truth):
/** 
 * Returns the content of this   {@code <gco:CharacterString>} as an {@code InternationalString}.
 * @return The character sequence for this {@code <gco:CharacterString>}.
 */
@Override public CharSequence toCharSequence(){
  String defaultValue=toString();
  if (defaultValue != null && contains(defaultValue)) {
    defaultValue=null;
  }
  DefaultInternationalString i18n=null;
  final TextGroup[] textGroup=this.textGroup;
  if (textGroup != null) {
    for (    final TextGroup group : textGroup) {
      if (group != null) {
        final LocalisedCharacterString[] localised=group.localized;
        if (localised != null) {
          for (          final LocalisedCharacterString text : localised) {
            if (text != null) {
              if (i18n == null) {
                i18n=new DefaultInternationalString(defaultValue);
              }
              i18n.add(text.locale,text.text);
            }
          }
        }
      }
    }
  }
  if (i18n == null && defaultValue != null) {
    return new SimpleInternationalString(defaultValue);
  }
  return i18n;
}
Program: 92057
Project: 92057
Buggy source:
/** 
 * Tests the formatting of an   {@link AbstractFeature}.
 */
@Test public void testFeature(){
  final Random random=TestUtilities.createRandomNumberGenerator();
  final AbstractFeature feature=FeatureTestCase.twinTown(random.nextBoolean());
  final FeatureFormat format=new FeatureFormat(Locale.US,null);
  final String text=format.format(feature);
  assertMultilinesEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",text);
}

Fixed version (ground truth):
/** 
 * Tests the formatting of an   {@link AbstractFeature}.
 */
@Test public void testFeature(){
  final Random random=TestUtilities.createRandomNumberGenerator();
  final boolean isSparse=random.nextBoolean();
  final DefaultFeatureType type=DefaultFeatureTypeTest.worldMetropolis();
  final AbstractFeature feature=isSparse ? new SparseFeature(type) : new DenseFeature(type);
  feature.setPropertyValue("String_Node_Str","String_Node_Str");
  feature.setPropertyValue("String_Node_Str",13185502);
  feature.setPropertyValue("String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str"));
  final FeatureFormat format=new FeatureFormat(Locale.US,null);
  final String text=format.format(feature);
  assertMultilinesEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",text);
}
Program: 92058
Project: 92058
Buggy source:
/** 
 * Returns the associated feature, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAssociationRole#getMaximumOccurs() maximum number} offeatures is restricted to 1 or 0. <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to  {@code org.opengis.feature.Feature}. This change is pending GeoAPI revision.</div>
 * @return The associated feature (may be {@code null}).
 * @throws IllegalStateException if this association contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract AbstractFeature getValue();

Fixed version (ground truth):
/** 
 * Returns the associated feature, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAssociationRole#getMaximumOccurs() maximum number} offeatures is restricted to 1 or 0. <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to  {@code org.opengis.feature.Feature}. This change is pending GeoAPI revision.</div>
 * @return The associated feature (may be {@code null}).
 * @throws IllegalStateException if this association contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract AbstractFeature getValue() throws IllegalStateException ;
Program: 92059
Project: 92059
Buggy source:
/** 
 * Verifies if the given property can be assigned to this feature.
 * @param name Shall be {@code property.getName().toString()}.
 * @param property The property to verify.
 */
final void verifyPropertyType(final String name,final Property property){
  final AbstractIdentifiedType pt, base=type.getProperty(name);
  if (property instanceof AbstractAttribute<?>) {
    pt=((AbstractAttribute<?>)property).getType();
  }
 else   if (property instanceof AbstractAssociation) {
    pt=((AbstractAssociation)property).getRole();
  }
 else {
    throw illegalPropertyType(base.getName(),property.getClass());
  }
  if (pt != base) {
    throw new IllegalArgumentException(base == null ? Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name) : Errors.format(Errors.Keys.MismatchedPropertyType_1,name));
  }
}

Fixed version (ground truth):
/** 
 * Verifies if the given property can be assigned to this feature.
 * @param name Shall be {@code property.getName().toString()}.
 * @param property The property to verify.
 */
final void verifyPropertyType(final String name,final Property property){
  final AbstractIdentifiedType pt, base=type.getProperty(name);
  if (property instanceof AbstractAttribute<?>) {
    pt=((AbstractAttribute<?>)property).getType();
  }
 else   if (property instanceof AbstractAssociation) {
    pt=((AbstractAssociation)property).getRole();
  }
 else {
    throw illegalPropertyType(base.getName(),property.getClass());
  }
  if (pt != base) {
    if (base == null) {
      throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
    }
 else {
      throw new IllegalArgumentException(Errors.format(Errors.Keys.MismatchedPropertyType_1,name));
    }
  }
}
Program: 92060
Project: 92060
Buggy source:
/** 
 * Returns the property (attribute, feature association or operation result) of the given name. If the property type is a parameterless   {@linkplain AbstractOperation operation}, then this method may return the result of   {@linkplain AbstractOperation#apply executing} the operationon this feature, at implementation choice. <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to  {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div> <div class="note"><b>Tip:</b> This method returns the property <em>instance</em>. If only the property <em>value</em> is desired, then   {@link #getPropertyValue(String)} is preferred since it gives to SIS achance to avoid the creation of  {@link AbstractAttribute} or {@link AbstractAssociation} instances.</div>
 * @param name The property name.
 * @return The property of the given name (never {@code null}).
 * @throws IllegalArgumentException If the given argument is not a property name of this feature.
 * @see #getPropertyValue(String)
 * @see DefaultFeatureType#getProperty(String)
 */
public abstract Object getProperty(final String name) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Returns the property (attribute, feature association or operation result) of the given name. If the property type is a parameterless   {@linkplain AbstractOperation operation}, then this method may return the result of   {@linkplain AbstractOperation#apply executing} the operationon this feature, at implementation choice. <div class="warning"><b>Warning:</b> In a future SIS version, the return type may be changed to  {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div> <div class="note"><b>Tip:</b> This method returns the property <em>instance</em>. If only the property <em>value</em> is desired, then   {@link #getPropertyValue(String)} is preferred since it gives to SIS achance to avoid the creation of  {@link AbstractAttribute} or {@link AbstractAssociation} instances.</div>
 * @param name The property name.
 * @return The property of the given name (never {@code null}).
 * @throws IllegalArgumentException if the given argument is not a property name of this feature.
 * @see #getPropertyValue(String)
 * @see DefaultFeatureType#getProperty(String)
 */
public abstract Object getProperty(final String name) throws IllegalArgumentException ;
Program: 92061
Project: 92061
Buggy source:
/** 
 * Returns the exception for a property type which neither an attribute or an association. This method is invoked after a   {@link PropertyType} has been found for the user-supplied name,but that property can not be stored in a  {@link Property} instance.
 */
static IllegalArgumentException unsupportedPropertyType(final GenericName name){
  return new IllegalArgumentException(Errors.format(Errors.Keys.CanNotInstantiate_1,name));
}

Fixed version (ground truth):
/** 
 * Returns the exception for a property type which is neither an attribute or an association. This method is invoked after a   {@link PropertyType} has been found for the user-supplied name,but that property can not be stored in or extracted from a  {@link Property} instance.
 */
static IllegalArgumentException unsupportedPropertyType(final GenericName name){
  return new IllegalArgumentException(Errors.format(Errors.Keys.CanNotInstantiate_1,name));
}
Program: 92063
Project: 92063
Buggy source:
/** 
 * Sets the property (attribute or feature association). The given property shall comply to the following conditions: <ul> <li>It must be non-null.</li> <li>Its   {@linkplain Property#getName() name} shall be the name of the property to set in this feature.</li><li>Its type shall be the same instance than the  {@linkplain DefaultFeatureType#getProperty(String) property type} defined by the feature type for the above name.In other words, the following condition shall hold:</li> </ul> {@preformat javaassert property.getType() == getType().getProperty(property.getName());}<div class="note"><b>Note:</b> This method is useful for storing non-default   {@code Attribute} or{@code FeatureAssociation} implementations in this feature. When default implementations are sufficient,the  {@link #setPropertyValue(String,Object)} method is preferred.</div><div class="warning"><b>Warning:</b> In a future SIS version, the argument may be changed to  {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div>
 * @param property The property to set.
 * @throws IllegalArgumentException if the type of the given property is not one of the typesknown to this feature, or if the property can not be set of an other reason.
 * @see #setPropertyValue(String,Object)
 */
public abstract void setProperty(final Object property) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Sets the property (attribute or feature association). The given property shall comply to the following conditions: <ul> <li>It must be non-null.</li> <li>Its   {@linkplain Property#getName() name} shall be the name of the property to set in this feature.</li><li>Its type shall be the same instance than the  {@linkplain DefaultFeatureType#getProperty(String) property type} defined by the feature type for the above name.In other words, the following condition shall hold:</li> </ul> {@preformat javaassert property.getType() == getType().getProperty(property.getName());}<div class="note"><b>Note:</b> This method is useful for storing non-default   {@code Attribute} or{@code FeatureAssociation} implementations in this feature. When default implementations are sufficient,the  {@link #setPropertyValue(String,Object)} method is preferred.</div><div class="warning"><b>Warning:</b> In a future SIS version, the argument may be changed to  {@code org.opengis.feature.Property}. This change is pending GeoAPI revision.</div>
 * @param property The property to set.
 * @throws IllegalArgumentException if the name of the given property is not a property name of this feature.
 * @throws IllegalArgumentException if the value of the given property is not valid.
 * @throws IllegalArgumentException if the property can not be set for another reason.
 * @see #setPropertyValue(String,Object)
 */
public abstract void setProperty(final Object property) throws IllegalArgumentException ;
Program: 92064
Project: 92064
Buggy source:
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws IllegalArgumentException If the given argument is not the name of an attribute orfeature association of this feature.
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) final Property createProperty(final String name) throws IllegalArgumentException {
  final AbstractIdentifiedType pt=type.getProperty(name);
  if (pt instanceof DefaultAttributeType<?>) {
    return ((DefaultAttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof DefaultAssociationRole) {
    return ((DefaultAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws IllegalArgumentException if the given argument is not the name of an attribute orfeature association of this feature.
 */
final Property createProperty(final String name) throws IllegalArgumentException {
  final AbstractIdentifiedType pt=type.getProperty(name);
  if (pt instanceof DefaultAttributeType<?>) {
    return ((DefaultAttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof DefaultAssociationRole) {
    return ((DefaultAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}
Program: 92065
Project: 92065
Buggy source:
/** 
 * Returns the index for the property of the given name, or   {@link DefaultFeatureType#OPERATION_INDEX}if the property is a parameterless operation.
 * @param name The property name.
 * @return The index for the property of the given name,or a negative value if the property is a parameterless operation.
 * @throws IllegalArgumentException If the given argument is not a property name of this feature.
 */
private int getIndex(final String name) throws IllegalArgumentException {
  final Integer index=indices.get(name);
  if (index != null) {
    return index;
  }
  throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}

Fixed version (ground truth):
/** 
 * Returns the index for the property of the given name, or   {@link DefaultFeatureType#OPERATION_INDEX}if the property is a parameterless operation.
 * @param name The property name.
 * @return The index for the property of the given name,or a negative value if the property is a parameterless operation.
 * @throws IllegalArgumentException if the given argument is not a property name of this feature.
 */
private int getIndex(final String name) throws IllegalArgumentException {
  final Integer index=indices.get(name);
  if (index != null) {
    return index;
  }
  throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}
Program: 92066
Project: 92066
Buggy source:
/** 
 * Sets the value for the property of the given name.
 * @param name  The attribute name.
 * @param value The new value for the given attribute (may be {@code null}).
 * @throws ClassCastException If the value is not assignable to the expected value class.
 * @throws IllegalArgumentException If the given value can not be assigned for an other reason.
 */
@Override public void setPropertyValue(final String name,Object value) throws IllegalArgumentException {
  ArgumentChecks.ensureNonNull("String_Node_Str",name);
  final int index=getIndex(name);
  if (index < 0) {
    setOperationValue(name,value);
    return;
  }
  if (properties == null) {
    final int n=indices.size();
    properties=(value != null) ? new Object[n] : new Property[n];
  }
  if (!(properties instanceof Property[])) {
    if (value != null) {
      if (!canSkipVerification(properties[index],value)) {
        value=verifyPropertyValue(name,value);
      }
      properties[index]=value;
      return;
    }
 else {
      wrapValuesInProperties();
    }
  }
  Property property=((Property[])properties)[index];
  if (property == null) {
    property=createProperty(name);
    properties[index]=property;
  }
  setPropertyValue(property,value);
}

Fixed version (ground truth):
/** 
 * Sets the value for the property of the given name.
 * @param name  The attribute name.
 * @param value The new value for the given attribute (may be {@code null}).
 * @throws ClassCastException If the value is not assignable to the expected value class.
 * @throws IllegalArgumentException If the given value can not be assigned for another reason.
 */
@Override public void setPropertyValue(final String name,Object value) throws IllegalArgumentException {
  ArgumentChecks.ensureNonNull("String_Node_Str",name);
  final int index=getIndex(name);
  if (index < 0) {
    setOperationValue(name,value);
    return;
  }
  if (properties == null) {
    final int n=indices.size();
    properties=(value != null) ? new Object[n] : new Property[n];
  }
  if (!(properties instanceof Property[])) {
    if (value != null) {
      if (!canSkipVerification(properties[index],value)) {
        value=verifyPropertyValue(name,value);
      }
      properties[index]=value;
      return;
    }
 else {
      wrapValuesInProperties();
    }
  }
  Property property=((Property[])properties)[index];
  if (property == null) {
    property=createProperty(name);
    properties[index]=property;
  }
  setPropertyValue(property,value);
}
Program: 92067
Project: 92067
Buggy source:
/** 
 * Returns a hash code value for this feature.
 * @return A hash code value.
 */
@Override public int hashCode(){
  return type.hashCode() + 37 * Arrays.hashCode(properties);
}

Fixed version (ground truth):
/** 
 * Returns a hash code value for this feature. This implementation computes the hash code using only the property values, not the   {@code Property} instances,in order to keep the hash code value stable before and after the  {@code properties} array is promoted from the{@code Object[]} type to the {@code Property[]} type.
 * @return A hash code value.
 */
@Override public int hashCode(){
  int code=1;
  if (properties != null) {
    if (properties instanceof Property[]) {
      for (      final Property p : (Property[])properties) {
        code=31 * code;
        final Object value;
        if (p instanceof AbstractAttribute<?>) {
          value=getAttributeValue((AbstractAttribute<?>)p);
        }
 else         if (p instanceof AbstractAssociation) {
          value=getAssociationValue((AbstractAssociation)p);
        }
 else {
          continue;
        }
        if (value != null) {
          code+=value.hashCode();
        }
      }
    }
 else {
      code=Arrays.hashCode(properties);
    }
  }
  return type.hashCode() + code;
}
Program: 92068
Project: 92068
Buggy source:
/** 
 * Sets the property (attribute, operation or association).
 * @param property The property to set.
 * @throws IllegalArgumentException if the type of the given property is not one of the typesknown to this feature.
 */
@Override public void setProperty(final Object property) throws IllegalArgumentException {
  ArgumentChecks.ensureNonNull("String_Node_Str",property);
  final String name=((Property)property).getName().toString();
  verifyPropertyType(name,(Property)property);
  if (!(properties instanceof Property[])) {
    wrapValuesInProperties();
  }
  properties[indices.get(name)]=property;
}

Fixed version (ground truth):
/** 
 * Sets the property (attribute, operation or association).
 * @param property The property to set.
 * @throws IllegalArgumentException if the type of the given property is not one of the typesknown to this feature, or if the property can not be set or another reason.
 */
@Override public void setProperty(final Object property) throws IllegalArgumentException {
  ArgumentChecks.ensureNonNull("String_Node_Str",property);
  final String name=((Property)property).getName().toString();
  verifyPropertyType(name,(Property)property);
  if (!(properties instanceof Property[])) {
    wrapValuesInProperties();
  }
  properties[indices.get(name)]=property;
}
Program: 92069
Project: 92069
Buggy source:
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof DenseFeature) {
    final DenseFeature that=(DenseFeature)obj;
    return type.equals(that.type) && Arrays.equals(properties,that.properties);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compares this feature with the given object for equality.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object obj){
  if (obj == this) {
    return true;
  }
  if (obj instanceof DenseFeature) {
    final DenseFeature that=(DenseFeature)obj;
    if (type.equals(that.type)) {
      final boolean asProperties=(properties instanceof Property[]);
      if (asProperties != (that.properties instanceof Property[])) {
        if (asProperties) {
          that.wrapValuesInProperties();
        }
 else {
          wrapValuesInProperties();
        }
      }
      return Arrays.equals(properties,that.properties);
    }
  }
  return false;
}
Program: 92071
Project: 92071
Buggy source:
/** 
 * Creates a new attribute of the given type initialized to the given values. Note that a   {@code null} value may not be the same as the default value.
 * @param type   Information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param values The initial values, or {@code null} for initializing to an empty list.
 */
@SuppressWarnings("String_Node_Str") MultiValuedAttribute(final DefaultAttributeType<V> type,final Object values){
  super(type);
  final Class<V> valueClass=type.getValueClass();
  if (values == null) {
    this.values=new CheckedArrayList<V>(valueClass);
  }
 else   if (((CheckedArrayList<?>)values).getElementType() == valueClass) {
    this.values=(CheckedArrayList<V>)values;
  }
 else {
    throw new ClassCastException();
  }
}

Fixed version (ground truth):
/** 
 * Creates a new attribute of the given type initialized to the given values. Note that a   {@code null} value may not be the same as the default value.
 * @param type   Information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param values The initial values, or {@code null} for initializing to an empty list.
 */
@SuppressWarnings("String_Node_Str") MultiValuedAttribute(final DefaultAttributeType<V> type,final Object values){
  super(type);
  final Class<V> valueClass=type.getValueClass();
  if (values == null) {
    this.values=new CheckedArrayList<V>(valueClass);
  }
 else {
    final Class<?> actual=((CheckedArrayList<?>)values).getElementType();
    if (actual == valueClass) {
      this.values=(CheckedArrayList<V>)values;
    }
 else {
      throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_3,"String_Node_Str",valueClass,actual));
    }
  }
}
Program: 92072
Project: 92072
Buggy source:
/** 
 * Sets the associated feature.
 * @param value The new value, or {@code null}.
 * @throws IllegalArgumentException If the given feature is not valid for this association.
 */
@Override public void setValue(final AbstractFeature value){
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
  }
  this.value=value;
}

Fixed version (ground truth):
/** 
 * Sets the associated feature.
 * @param value The new value, or {@code null}.
 * @throws IllegalArgumentException If the given feature is not valid for this association.
 */
@Override public void setValue(final AbstractFeature value) throws IllegalArgumentException {
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
  }
  this.value=value;
}
Program: 92073
Project: 92073
Buggy source:
/** 
 * Ensures that storing a feature of the given type is valid for an association expecting the given base type.
 */
final void ensureValid(final FeatureType base,final FeatureType type){
  if (base != type && !DefaultFeatureType.maybeAssignableFrom(base,type)) {
    throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentClass_3,getName(),base.getName(),type.getName()));
  }
}

Fixed version (ground truth):
/** 
 * Ensures that storing a feature of the given type is valid for an association expecting the given base type.
 */
final void ensureValid(final FeatureType base,final FeatureType type){
  if (base != type && !DefaultFeatureType.maybeAssignableFrom(base,type)) {
    throw new InvalidPropertyValueException(Errors.format(Errors.Keys.IllegalArgumentClass_3,getName(),base.getName(),type.getName()));
  }
}
Program: 92074
Project: 92074
Buggy source:
/** 
 * Returns the associated feature, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAssociationRole#getMaximumOccurs() maximum number} offeatures is restricted to 1 or 0.
 * @return The associated feature (may be {@code null}).
 * @throws IllegalStateException if this association contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract Feature getValue();

Fixed version (ground truth):
/** 
 * Returns the associated feature, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAssociationRole#getMaximumOccurs() maximum number} offeatures is restricted to 1 or 0.
 * @return The associated feature (may be {@code null}).
 * @throws MultiValuedPropertyException if this association contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract Feature getValue() throws MultiValuedPropertyException ;
Program: 92075
Project: 92075
Buggy source:
/** 
 * Sets the features. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Feature)}.</p>
 * @param values The new values.
 * @throws IllegalArgumentException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends Feature> values) throws IllegalArgumentException {
  super.setValues(values);
}

Fixed version (ground truth):
/** 
 * Sets the features. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Feature)}.</p>
 * @param values The new values.
 * @throws InvalidPropertyValueException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends Feature> values) throws InvalidPropertyValueException {
  super.setValues(values);
}
Program: 92076
Project: 92076
Buggy source:
/** 
 * Sets the associated feature. <div class="section">Validation</div> The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking the   {@link #quality()} method.
 * @param value The new value, or {@code null}.
 * @throws IllegalArgumentException If the given feature is not valid for this association.
 * @see AbstractFeature#setPropertyValue(String,Object)
 */
@Override public abstract void setValue(final Feature value) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Sets the associated feature. <div class="section">Validation</div> The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking the   {@link #quality()} method.
 * @param value The new value, or {@code null}.
 * @throws InvalidPropertyValueException If the given feature is not valid for this association.
 * @see AbstractFeature#setPropertyValue(String,Object)
 */
@Override public abstract void setValue(final Feature value) throws InvalidPropertyValueException ;
Program: 92077
Project: 92077
Buggy source:
/** 
 * Returns the attribute value, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAttributeType#getMaximumOccurs() maximum number}of attribute values is restricted to 1 or 0.
 * @return The attribute value (may be {@code null}).
 * @throws IllegalStateException if this attribute contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract V getValue() throws IllegalStateException ;

Fixed version (ground truth):
/** 
 * Returns the attribute value, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAttributeType#getMaximumOccurs() maximum number}of attribute values is restricted to 1 or 0.
 * @return The attribute value (may be {@code null}).
 * @throws MultiValuedPropertyException if this attribute contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract V getValue() throws MultiValuedPropertyException ;
Program: 92078
Project: 92078
Buggy source:
/** 
 * Sets the attribute values. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Object)}.</p>
 * @param values The new values.
 * @throws IllegalArgumentException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends V> values) throws IllegalArgumentException {
  super.setValues(values);
}

Fixed version (ground truth):
/** 
 * Sets the attribute values. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Object)}.</p>
 * @param values The new values.
 * @throws InvalidPropertyValueException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException {
  super.setValues(values);
}