Program: 91701
Project: 91701
Buggy source:
/** 
 * Returns the name of the type of values that the given property can take. The type of value can be a   {@link Class}, a   {@link FeatureType} or another {@code PropertyType}depending on given argument: <ul> <li>If   {@code property} is an {@link AttributeType}, then this method gets the  {@linkplain DefaultAttributeType#getValueClass() value class} and{@linkplain DefaultNameFactory#toTypeName(Class) maps that class to a name}.</li> <li>If   {@code property} is a {@link FeatureAssociationRole}, then this method gets the name of the   {@linkplain DefaultAssociationRole#getValueType() value type}. This methods can work even if the associated   {@code FeatureType} is not yet resolved.</li><li>If  {@code property} is an {@link Operation}, then this method returns the name of the  {@linkplain AbstractOperation#getResult() result type}.</li> </ul>
 * @param property  the property for which to get the name of value type.
 * @return the name of value type, or {@code null} if none.
 * @since 0.8
 */
public static GenericName getValueTypeName(final PropertyType property){
  if (property instanceof FeatureAssociationRole) {
    return DefaultAssociationRole.getValueTypeName((FeatureAssociationRole)property);
  }
 else   if (property instanceof AttributeType<?>) {
    final DefaultNameFactory factory=DefaultFactories.forBuildin(NameFactory.class,DefaultNameFactory.class);
    return factory.toTypeName(((AttributeType<?>)property).getValueClass());
  }
 else   if (property instanceof Operation) {
    final IdentifiedType result=((Operation)property).getResult();
    if (result != null) {
      return result.getName();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the name of the type of values that the given property can take. The type of value can be a   {@link Class}, a   {@link org.opengis.feature.FeatureType}or another   {@code PropertyType} depending on given argument:<ul> <li>If  {@code property} is an {@link AttributeType}, then this method gets the  {@linkplain DefaultAttributeType#getValueClass() value class} and{@linkplain DefaultNameFactory#toTypeName(Class) maps that class to a name}.</li> <li>If   {@code property} is a {@link FeatureAssociationRole}, then this method gets the name of the   {@linkplain DefaultAssociationRole#getValueType() value type}. This methods can work even if the associated   {@code FeatureType} is not yet resolved.</li><li>If  {@code property} is an {@link Operation}, then this method returns the name of the  {@linkplain AbstractOperation#getResult() result type}.</li> </ul>
 * @param property  the property for which to get the name of value type.
 * @return the name of value type, or {@code null} if none.
 * @since 0.8
 */
public static GenericName getValueTypeName(final PropertyType property){
  if (property instanceof FeatureAssociationRole) {
    return DefaultAssociationRole.getValueTypeName((FeatureAssociationRole)property);
  }
 else   if (property instanceof AttributeType<?>) {
    final DefaultNameFactory factory=DefaultFactories.forBuildin(NameFactory.class,DefaultNameFactory.class);
    return factory.toTypeName(((AttributeType<?>)property).getValueClass());
  }
 else   if (property instanceof Operation) {
    final IdentifiedType result=((Operation)property).getResult();
    if (result != null) {
      return result.getName();
    }
  }
  return null;
}