nus-yam/ex-repair huggingface dataset:
Program: 91956
Project: 91956
Buggy source:
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91957
Project: 91957
Buggy source:
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP));
  this.isCRS=isCRS;
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP,Option.DEBUG));
  this.isCRS=isCRS;
}
Program: 91959
Project: 91959
Buggy source:
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91961
Project: 91961
Buggy source:
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  err.println(Exceptions.formatChainedMessages(locale,message,e));
}

Fixed version (ground truth):
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  if (debug) {
    e.printStackTrace(err);
  }
 else {
    err.println(Exceptions.formatChainedMessages(locale,message,e));
  }
}
Program: 91962
Project: 91962
Buggy source:
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP,Option.DEBUG));
}
Program: 91963
Project: 91963
Buggy source:
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}

Fixed version (ground truth):
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(args,e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(args,e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}
Program: 91964
Project: 91964
Buggy source:
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 */
private static void error(final Exception e){
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    err.println(e.getLocalizedMessage());
    err.flush();
  }
 else {
    final PrintStream err=System.err;
    err.println(e.getLocalizedMessage());
    err.flush();
  }
}

Fixed version (ground truth):
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 * @param args The command line arguments, used only for detecting if the {@code --debug} option was present.
 */
private static void error(final String[] args,final Exception e){
  final boolean debug=ArraysExt.containsIgnoreCase(args,Option.PREFIX + "String_Node_Str");
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
 else {
    @SuppressWarnings("String_Node_Str") final PrintStream err=System.err;
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
}
Program: 91965
Project: 91965
Buggy source:
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91966
Project: 91966
Buggy source:
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP));
  this.isCRS=isCRS;
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP,Option.DEBUG));
  this.isCRS=isCRS;
}
Program: 91968
Project: 91968
Buggy source:
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91970
Project: 91970
Buggy source:
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  err.println(Exceptions.formatChainedMessages(locale,message,e));
}

Fixed version (ground truth):
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  if (debug) {
    e.printStackTrace(err);
  }
 else {
    err.println(Exceptions.formatChainedMessages(locale,message,e));
  }
}
Program: 91972
Project: 91972
Buggy source:
/** 
 * Constructs a set to be filled using the specified iterator. Iteration with the given iterator will occur only when needed.
 * @param iterator The iterator to use for filling this set.
 */
public LazySet(final Iterator<? extends E> iterator){
  Objects.requireNonNull(sourceIterator);
  sourceIterator=iterator;
  source=null;
  createCache();
}

Fixed version (ground truth):
/** 
 * Constructs a set to be filled using the specified iterator. Iteration with the given iterator will occur only when needed.
 * @param iterator The iterator to use for filling this set.
 */
public LazySet(final Iterator<? extends E> iterator){
  Objects.requireNonNull(iterator);
  sourceIterator=iterator;
  source=null;
  createCache();
}
Program: 91973
Project: 91973
Buggy source:
/** 
 * Restores the contextual unit to its previous state before the call to   {@link #addContextualUnit(Unit)}. This method is used in the following pattern:  {@preformat javafinal Unit<?> previous = formatter.addContextualUnit(unit); // ... format some WKT elements here. formatter.restoreContextualUnit(unit, previous);}
 * @param unit The value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
 * @param previous The value returned by {@code addContextualUnit(unit)} (can be {@code null}).
 * @throws IllegalStateException if this method has not been invoked in the pattern documented above.
 * @since 0.6
 */
public void restoreContextualUnit(final Unit<?> unit,final Unit<?> previous){
  if (previous == null) {
    if (unit != null && units.remove(unit.toSI()) != unit) {
      if (!convention.usesCommonUnits) {
        throw new IllegalStateException();
      }
    }
  }
 else   if (units.put(previous.toSI(),previous) != unit) {
    throw new IllegalStateException();
  }
}

Fixed version (ground truth):
/** 
 * Restores the contextual unit to its previous state before the call to   {@link #addContextualUnit(Unit)}. This method is used in the following pattern:  {@preformat javafinal Unit<?> previous = formatter.addContextualUnit(unit); // ... format some WKT elements here. formatter.restoreContextualUnit(unit, previous);}
 * @param unit The value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
 * @param previous The value returned by {@code addContextualUnit(unit)} (can be {@code null}).
 * @throws IllegalStateException if this method has not been invoked in the pattern documented above.
 * @since 0.6
 */
public void restoreContextualUnit(final Unit<?> unit,final Unit<?> previous){
  if (previous == null) {
    if (unit != null && units.remove(unit.toSI()) != unit) {
      if (!convention.usesCommonUnits) {
        throw new IllegalStateException();
      }
    }
    hasContextualUnit&=~1;
  }
 else   if (units.put(previous.toSI(),previous) != unit) {
    throw new IllegalStateException();
  }
}
Program: 91974
Project: 91974
Buggy source:
/** 
 * Returns the name and description for the specified   {@link CoordinateSystemAxis} code.Many axes share the same name and description, so it is worth to cache them.
 */
private AxisName getAxisName(final Integer code) throws FactoryException {
}

Fixed version (ground truth):
/** 
 * Returns the name and description for the specified   {@link CoordinateSystemAxis} code.Many axes share the same name and description, so it is worth to cache them.
 */
private AxisName getAxisName(final Integer code) throws FactoryException, SQLException {
}
Program: 91975
Project: 91975
Buggy source:
/** 
 * Restores the contextual unit to its previous state before the call to   {@link #addContextualUnit(Unit)}. This method is used in the following pattern:  {@preformat javafinal Unit<?> previous = formatter.addContextualUnit(unit); // ... format some WKT elements here. formatter.restoreContextualUnit(unit, previous);}
 * @param unit The value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
 * @param previous The value returned by {@code addContextualUnit(unit)} (can be {@code null}).
 * @throws IllegalStateException if this method has not been invoked in the pattern documented above.
 * @since 0.6
 */
public void restoreContextualUnit(final Unit<?> unit,final Unit<?> previous){
  if (previous == null) {
    if (unit != null && units.remove(unit.toSI()) != unit) {
      if (!convention.usesCommonUnits) {
        throw new IllegalStateException();
      }
    }
  }
 else   if (units.put(previous.toSI(),previous) != unit) {
    throw new IllegalStateException();
  }
}

Fixed version (ground truth):
/** 
 * Restores the contextual unit to its previous state before the call to   {@link #addContextualUnit(Unit)}. This method is used in the following pattern:  {@preformat javafinal Unit<?> previous = formatter.addContextualUnit(unit); // ... format some WKT elements here. formatter.restoreContextualUnit(unit, previous);}
 * @param unit The value given in argument to {@code addContextualUnit(unit)} (can be {@code null}).
 * @param previous The value returned by {@code addContextualUnit(unit)} (can be {@code null}).
 * @throws IllegalStateException if this method has not been invoked in the pattern documented above.
 * @since 0.6
 */
public void restoreContextualUnit(final Unit<?> unit,final Unit<?> previous){
  if (previous == null) {
    if (unit != null && units.remove(unit.toSI()) != unit) {
      if (!convention.usesCommonUnits) {
        throw new IllegalStateException();
      }
    }
    hasContextualUnit&=~1;
  }
 else   if (units.put(previous.toSI(),previous) != unit) {
    throw new IllegalStateException();
  }
}
Program: 91976
Project: 91976
Buggy source:
/** 
 * Returns the name and description for the specified   {@link CoordinateSystemAxis} code.Many axes share the same name and description, so it is worth to cache them.
 */
private AxisName getAxisName(final Integer code) throws FactoryException {
}

Fixed version (ground truth):
/** 
 * Returns the name and description for the specified   {@link CoordinateSystemAxis} code.Many axes share the same name and description, so it is worth to cache them.
 */
private AxisName getAxisName(final Integer code) throws FactoryException, SQLException {
}
Program: 91979
Project: 91979
Buggy source:
/** 
 * Returns the grid of the given name. This method returns the cached instance if it still exists, or load the grid otherwise.
 * @param file Name of the datum shift grid file to load.
 */
static DatumShiftGridFile<Angle,Angle> getOrLoad(final Path file) throws FactoryException {
  final Path resolved=DataDirectory.DATUM_CHANGES.resolve(file).toAbsolutePath();
  DatumShiftGridFile<?,?> grid=DatumShiftGridFile.CACHE.peek(resolved);
  if (grid == null) {
    final Cache.Handler<DatumShiftGridFile<?,?>> handler=DatumShiftGridFile.CACHE.lock(resolved);
    try {
      grid=handler.peek();
      if (grid == null) {
        try (final ReadableByteChannel in=Files.newByteChannel(resolved)){
          DatumShiftGridLoader.log(NTv2.class,file);
          final Loader loader=new Loader(in,file);
          grid=loader.readGrid();
          loader.reportWarnings();
        }
 catch (        IOException|NoninvertibleTransformException|RuntimeException e) {
          throw new FactoryException(Errors.format(Errors.Keys.CanNotParseFile_2,"String_Node_Str",file),e);
        }
        grid=grid.useSharedData();
      }
    }
  finally {
      handler.putAndUnlock(grid);
    }
  }
  return grid.castTo(Angle.class,Angle.class);
}

Fixed version (ground truth):
/** 
 * Returns the grid of the given name. This method returns the cached instance if it still exists, or load the grid otherwise.
 * @param file Name of the datum shift grid file to load.
 */
@SuppressWarnings("String_Node_Str") static DatumShiftGridFile<Angle,Angle> getOrLoad(final Path file) throws FactoryException {
  final Path resolved=DataDirectory.DATUM_CHANGES.resolve(file).toAbsolutePath();
  DatumShiftGridFile<?,?> grid=DatumShiftGridFile.CACHE.peek(resolved);
  if (grid == null) {
    final Cache.Handler<DatumShiftGridFile<?,?>> handler=DatumShiftGridFile.CACHE.lock(resolved);
    try {
      grid=handler.peek();
      if (grid == null) {
        try (final ReadableByteChannel in=Files.newByteChannel(resolved)){
          DatumShiftGridLoader.log(NTv2.class,file);
          final Loader loader=new Loader(in,file);
          grid=loader.readGrid();
          loader.reportWarnings();
        }
 catch (        IOException|NoninvertibleTransformException|RuntimeException e) {
          final String message=Errors.format(Errors.Keys.CanNotParseFile_2,"String_Node_Str",file);
          if (e instanceof NoSuchFileException) {
            throw new MissingFactoryResourceException(message,e);
          }
 else {
            throw new FactoryDataException(message,e);
          }
        }
        grid=grid.useSharedData();
      }
    }
  finally {
      handler.putAndUnlock(grid);
    }
  }
  return grid.castTo(Angle.class,Angle.class);
}
Program: 91982
Project: 91982
Buggy source:
/** 
 * Returns all subgroups with the specified name. <p>This method do not create new groups: if the requested group is optional (i.e. <code>  {@linkplain DefaultParameterDescriptor#getMinimumOccurs() minimumOccurs} == 0</code>)and no value were defined previously, then this method returns an empty set.</p>
 * @param name The name of the parameter to search for.
 * @return The set of all parameter group for the given name.
 * @throws ParameterNotFoundException If no descriptor was found for the given name.
 */
@Override public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
  ArgumentChecks.ensureNonNull("String_Node_Str",name);
  final ParameterValueList values=this.values;
  final List<ParameterValueGroup> groups=new ArrayList<>(4);
  final int size=values.size();
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptorGroup) {
      if (isHeuristicMatchForName(descriptor,name)) {
        groups.add((ParameterValueGroup)values.get(i));
      }
    }
  }
  if (groups.isEmpty()) {
    final ParameterDescriptorGroup descriptor=values.descriptor;
    if (!(descriptor.descriptor(name) instanceof ParameterDescriptorGroup)) {
      throw new ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,descriptor.getName(),name),name);
    }
  }
  return groups;
}

Fixed version (ground truth):
/** 
 * Returns all subgroups with the specified name. <p>This method do not create new groups: if the requested group is optional (i.e. <code>  {@linkplain DefaultParameterDescriptor#getMinimumOccurs() minimumOccurs} == 0</code>)and no value were defined previously, then this method returns an empty set.</p>
 * @param name The name of the parameter to search for.
 * @return The set of all parameter group for the given name.
 * @throws ParameterNotFoundException if no descriptor was found for the given name.
 */
@Override public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException {
  ArgumentChecks.ensureNonNull("String_Node_Str",name);
  final ParameterValueList values=this.values;
  final List<ParameterValueGroup> groups=new ArrayList<>(4);
  final int size=values.size();
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptorGroup) {
      if (IdentifiedObjects.isHeuristicMatchForName(descriptor,name)) {
        groups.add((ParameterValueGroup)values.get(i));
      }
    }
  }
  if (groups.isEmpty()) {
    final ParameterDescriptorGroup descriptor=values.descriptor;
    if (!(descriptor.descriptor(name) instanceof ParameterDescriptorGroup)) {
      throw new ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,Verifier.getDisplayName(descriptor),name),name);
    }
  }
  return groups;
}
Program: 91983
Project: 91983
Buggy source:
/** 
 * Returns the value in this group for the specified name if it exists, or   {@code null} if none.This method does not create any new  {@code ParameterValue} instance.
 * @see #isKnownImplementation()
 */
@Override ParameterValue<?> parameterIfExist(final String name) throws ParameterNotFoundException {
  final ParameterValueList values=this.values;
  final int size=values.size();
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptor<?>) {
      if (name.equals(descriptor.getName().toString())) {
        return (ParameterValue<?>)values.get(i);
      }
    }
  }
  int fallback=-1;
  int ambiguity=-1;
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptor<?>) {
      if (isHeuristicMatchForName(descriptor,name)) {
        if (fallback < 0) {
          fallback=i;
        }
 else {
          ambiguity=i;
        }
      }
    }
  }
  if (fallback >= 0) {
    if (ambiguity < 0) {
      return (ParameterValue<?>)values.get(fallback);
    }
    throw new ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,IdentifiedObjects.toString(values.descriptor(fallback).getName()),IdentifiedObjects.toString(values.descriptor(ambiguity).getName()),name),name);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the value in this group for the specified name if it exists, or   {@code null} if none.This method does not create any new  {@code ParameterValue} instance.
 * @see #isKnownImplementation()
 */
@Override ParameterValue<?> parameterIfExist(final String name) throws ParameterNotFoundException {
  final ParameterValueList values=this.values;
  final int size=values.size();
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptor<?>) {
      if (name.equals(descriptor.getName().toString())) {
        return (ParameterValue<?>)values.get(i);
      }
    }
  }
  int fallback=-1;
  int ambiguity=-1;
  for (int i=0; i < size; i++) {
    final GeneralParameterDescriptor descriptor=values.descriptor(i);
    if (descriptor instanceof ParameterDescriptor<?>) {
      if (IdentifiedObjects.isHeuristicMatchForName(descriptor,name)) {
        if (fallback < 0) {
          fallback=i;
        }
 else {
          ambiguity=i;
        }
      }
    }
  }
  if (fallback >= 0) {
    if (ambiguity < 0) {
      return (ParameterValue<?>)values.get(fallback);
    }
    throw new ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,IdentifiedObjects.toString(values.descriptor(fallback).getName()),IdentifiedObjects.toString(values.descriptor(ambiguity).getName()),name),name);
  }
  return null;
}
Program: 91984
Project: 91984
Buggy source:
/** 
 * Returns a hash value for this parameter.
 * @return The hash code value. This value doesn't need to be the samein past or future versions of this class.
 */
@Override public int hashCode(){
  return values.descriptor.hashCode() ^ values.hashCode();
}

Fixed version (ground truth):
/** 
 * Returns a hash value for this parameter.
 * @return The hash code value. This value does not need to be the samein past or future versions of this class.
 */
@Override public int hashCode(){
  return values.descriptor.hashCode() ^ values.hashCode();
}
Program: 91985
Project: 91985
Buggy source:
/** 
 * Creates a new subgroup of the specified name, and adds it to the list of subgroups. The argument shall be the name of a   {@linkplain DefaultParameterDescriptorGroup descriptor group}which is a child of this group. <div class="note"><b>API note:</b> There is no   {@code removeGroup(String)} method. To remove a group, users shall inspect the{@link #values()} list, decide which occurrences to remove if there is many of them for thesame name, and whether to iterate recursively into sub-groups or not.</div>
 * @param name The name of the parameter group to create.
 * @return A newly created parameter group for the given name.
 * @throws ParameterNotFoundException If no descriptor was found for the given name.
 * @throws InvalidParameterCardinalityException If this parameter group already contains the{@linkplain ParameterDescriptorGroup#getMaximumOccurs() maximum number of occurrences}of subgroups of the given name.
 */
@Override public ParameterValueGroup addGroup(final String name) throws ParameterNotFoundException, InvalidParameterCardinalityException {
  final ParameterValueList values=this.values;
  final ParameterDescriptorGroup descriptor=values.descriptor;
  final GeneralParameterDescriptor child=descriptor.descriptor(name);
  if (!(child instanceof ParameterDescriptorGroup)) {
    throw new ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,descriptor.getName(),name),name);
  }
  final ParameterValueGroup value=((ParameterDescriptorGroup)child).createValue();
  values.add(value);
  return value;
}

Fixed version (ground truth):
/** 
 * Creates a new subgroup of the specified name, and adds it to the list of subgroups. The argument shall be the name of a   {@linkplain DefaultParameterDescriptorGroup descriptor group}which is a child of this group. <div class="note"><b>API note:</b> There is no   {@code removeGroup(String)} method. To remove a group, users shall inspect the{@link #values()} list, decide which occurrences to remove if there is many of them for thesame name, and whether to iterate recursively into sub-groups or not.</div>
 * @param name The name of the parameter group to create.
 * @return A newly created parameter group for the given name.
 * @throws ParameterNotFoundException if no descriptor was found for the given name.
 * @throws InvalidParameterCardinalityException if this parameter group already contains the{@linkplain ParameterDescriptorGroup#getMaximumOccurs() maximum number of occurrences}of subgroups of the given name.
 */
@Override public ParameterValueGroup addGroup(final String name) throws ParameterNotFoundException, InvalidParameterCardinalityException {
  final ParameterValueList values=this.values;
  final ParameterDescriptorGroup descriptor=values.descriptor;
  final GeneralParameterDescriptor child=descriptor.descriptor(name);
  if (!(child instanceof ParameterDescriptorGroup)) {
    throw new ParameterNotFoundException(Errors.format(Errors.Keys.ParameterNotFound_2,descriptor.getName(),name),name);
  }
  final ParameterValueGroup value=((ParameterDescriptorGroup)child).createValue();
  values.add(value);
  return value;
}
Program: 91987
Project: 91987
Buggy source:
/** 
 * Returns the parameter of the given name, or   {@code null} if it does not exist.The default implementation iterates over the  {@link #values()} and compares the descriptor names.The  {@link DefaultParameterValueGroup} subclass will override this method with a more efficientimplementation which avoid creating some deferred parameters.
 */
ParameterValue<?> parameterIfExist(final String name) throws ParameterNotFoundException {
  for (  final GeneralParameterValue value : values()) {
    if (value instanceof ParameterValue<?>) {
      if (isHeuristicMatchForName(value.getDescriptor(),name)) {
        return (ParameterValue<?>)value;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the parameter of the given name, or   {@code null} if it does not exist.The default implementation iterates over the  {@link #values()} and compares the descriptor names.The  {@link DefaultParameterValueGroup} subclass will override this method with a more efficientimplementation which avoid creating some deferred parameters.
 */
@SuppressWarnings("String_Node_Str") ParameterValue<?> parameterIfExist(final String name) throws ParameterNotFoundException {
  ParameterValue<?> fallback=null;
  ParameterValue<?> ambiguity=null;
  for (  final GeneralParameterValue value : values()) {
    if (value instanceof ParameterValue<?>) {
      final ParameterValue<?> param=(ParameterValue<?>)value;
      final ParameterDescriptor<?> descriptor=param.getDescriptor();
      if (name.equals(descriptor.getName().toString())) {
        return param;
      }
      if (isHeuristicMatchForName(descriptor,name)) {
        if (fallback == null) {
          fallback=param;
        }
 else {
          ambiguity=param;
        }
      }
    }
  }
  if (ambiguity != null) {
    throw new ParameterNotFoundException(Errors.format(Errors.Keys.AmbiguousName_3,IdentifiedObjects.toString(fallback.getDescriptor().getName()),IdentifiedObjects.toString(ambiguity.getDescriptor().getName()),name),name);
  }
  return fallback;
}
Program: 91988
Project: 91988
Buggy source:
/** 
 * Returns a modifiable copy of this parameter.
 */
@Override public DefaultParameterValue<T> clone(){
  return new DefaultParameterValue<>(this);
}

Fixed version (ground truth):
/** 
 * Returns a modifiable copy of this parameter.
 */
@Override @SuppressWarnings("String_Node_Str") public DefaultParameterValue<T> clone(){
  return new DefaultParameterValue<>(this);
}
Program: 91989
Project: 91989
Buggy source:
/** 
 * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element. If this inverse math transform has any parameter values, then this method formats the WKT as in the   {@linkplain AbstractMathTransform#formatWKT super-class method}. Otherwise this method formats the math transform as an   {@code "Inverse_MT"} entity.<div class="note"><b>Compatibility note:</b> {@code Param_MT} and {@code Inverse_MT} are defined in the WKT 1 specification only.</div>
 * @param formatter The formatter to use.
 * @return The WKT element name, which is {@code "Param_MT"} or{@code "Inverse_MT"} in the default implementation.
 */
@Override protected String formatTo(final Formatter formatter){
  final ParameterValueGroup parameters=getParameterValues();
  if (parameters != null) {
    WKTUtilities.appendParamMT(parameters,formatter);
    return WKTKeywords.Param_MT;
  }
 else {
    formatter.append((FormattableObject)AbstractMathTransform.this);
    return WKTKeywords.Inverse_MT;
  }
}

Fixed version (ground truth):
/** 
 * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element. If this inverse math transform has any parameter values, then this method formats the WKT as in the   {@linkplain AbstractMathTransform#formatWKT super-class method}. Otherwise this method formats the math transform as an   {@code "Inverse_MT"} entity.<div class="note"><b>Compatibility note:</b> {@code Param_MT} and {@code Inverse_MT} are defined in the WKT 1 specification only.</div>
 * @param formatter The formatter to use.
 * @return The WKT element name, which is {@code "Param_MT"} or{@code "Inverse_MT"} in the default implementation.
 */
@Override protected String formatTo(final Formatter formatter){
  final ParameterValueGroup parameters=getParameterValues();
  if (parameters != null) {
    WKTUtilities.appendParamMT(parameters,formatter);
    return WKTKeywords.Param_MT;
  }
 else {
    formatter.newLine();
    formatter.append((FormattableObject)AbstractMathTransform.this);
    return WKTKeywords.Inverse_MT;
  }
}
Program: 91990
Project: 91990
Buggy source:
/** 
 * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters. <div class="note"><b>Compatibility note:</b>  {@code Param_MT} is defined in the WKT 1 specification only.If the  {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2,then this method silently uses the WKT 1 convention without raising an error.</div>
 * @return {@code "Param_MT"}.
 */
@Override protected String formatTo(final Formatter formatter){
  if (inverse) {
    formatter.append(new WKT(false));
    return WKTKeywords.Inverse_MT;
  }
 else {
    WKTUtilities.appendParamMT(ContextualParameters.this,formatter);
    return WKTKeywords.Param_MT;
  }
}

Fixed version (ground truth):
/** 
 * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters. <div class="note"><b>Compatibility note:</b>  {@code Param_MT} is defined in the WKT 1 specification only.If the  {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2,then this method silently uses the WKT 1 convention without raising an error.</div>
 * @return {@code "Param_MT"}.
 */
@Override protected String formatTo(final Formatter formatter){
  if (inverse) {
    formatter.newLine();
    formatter.append(new WKT(false));
    return WKTKeywords.Inverse_MT;
  }
 else {
    WKTUtilities.appendParamMT(ContextualParameters.this,formatter);
    return WKTKeywords.Param_MT;
  }
}
Program: 91992
Project: 91992
Buggy source:
/** 
 * Tests the WKT formatting of   {@link NormalizedProjection}. For the Mercator projection, we expect only the ellipsoid eccentricity. We expect nothing else because all other parameters are used by the (de)normalization affine transforms instead than the   {@link Mercator} class itself.
 * @see LambertConicConformalTest#testNormalizedWKT()
 */
@Test public void testNormalizedWKT(){
  createNormalizedProjection(true);
  assertWktEquals("String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Tests the WKT formatting of   {@link NormalizedProjection}. For the Mercator projection, we expect only the ellipsoid eccentricity. We expect nothing else because all other parameters are used by the (de)normalization affine transforms instead than the   {@link Mercator} class itself.
 * @throws NoninvertibleTransformException should never happen.
 * @see LambertConicConformalTest#testNormalizedWKT()
 */
@Test public void testNormalizedWKT() throws NoninvertibleTransformException {
  createNormalizedProjection(true);
  assertWktEquals("String_Node_Str" + "String_Node_Str");
  transform=transform.inverse();
  assertWktEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}
Program: 91993
Project: 91993
Buggy source:
/** 
 * Returns the sequence of <cite>normalization</cite> →   {@code this} → <cite>denormalization</cite> transformsas a whole. The transform returned by this method expects (<var>longitude</var>, <var>latitude</var>) coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. <p>The non-linear part of the returned transform will be  {@code this} transform, except if the ellipsoidis spherical. In the later case,  {@code this} transform will be replaced by a simplified implementation.</p>
 * @param factory The factory to use for creating the transform.
 * @return The map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates.
 * @throws FactoryException if an error occurred while creating a transform.
 */
@Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException {
  if (Double.isNaN(χ0)) {
    final Double φ0=context.getValue(LATITUDE_OF_ORIGIN);
    if (φ0 != null && abs(φ0 - 90) < Formulas.ANGULAR_TOLERANCE) {
      return delegate(factory,PolarStereographicA.NAME);
    }
  }
  ObliqueStereographic kernel=this;
  if (excentricity == 0) {
    kernel=new Spherical(this);
  }
  return context.completeTransform(factory,kernel);
}

Fixed version (ground truth):
/** 
 * Returns the sequence of <cite>normalization</cite> →   {@code this} → <cite>denormalization</cite> transformsas a whole. The transform returned by this method expects (<var>longitude</var>, <var>latitude</var>) coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. <p>The non-linear part of the returned transform will be  {@code this} transform, except if the ellipsoidis spherical. In the later case,  {@code this} transform will be replaced by a simplified implementation.</p>
 * @param factory The factory to use for creating the transform.
 * @return The map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates.
 * @throws FactoryException if an error occurred while creating a transform.
 */
@Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException {
  if (Double.isNaN(χ0)) {
    final Double φ0=context.getValue(LATITUDE_OF_ORIGIN);
    if (φ0 != null && abs(abs(φ0) - 90) < Formulas.ANGULAR_TOLERANCE) {
      return delegate(factory,PolarStereographicA.NAME);
    }
  }
  ObliqueStereographic kernel=this;
  if (excentricity == 0) {
    kernel=new Spherical(this);
  }
  return context.completeTransform(factory,kernel);
}
Program: 91994
Project: 91994
Buggy source:
/** 
 * Returns a unique instance of the given range.
 */
static <E extends Number & Comparable<? super E>,T extends NumberRange<E>>T unique(final T range){
  return POOL.unique(range);
}

Fixed version (ground truth):
/** 
 * Returns a unique instance of the given range, except if the range is empty. <div class="note"><b>Rational:</b> we exclude empty ranges because the   {@link Range#equals(Object)} consider them as equal.Consequently if empty ranges were included in the pool, this method would return in some occasions an empty range with different values than the given  {@code range} argument.</div>
 */
static <E extends Number & Comparable<? super E>,T extends NumberRange<E>>T unique(T range){
  if (!range.isEmpty()) {
    range=POOL.unique(range);
  }
  return range;
}
Program: 91995
Project: 91995
Buggy source:
/** 
 * Compares this range with the given object for equality.
 * @param object The object to compare with this range for equality.
 * @return {@code true} if the given object is equal to this range.
 */
@Override public boolean equals(final Object object){
  if (object == this) {
    return true;
  }
  if (object != null && object.getClass() == getClass()) {
    final Range<?> other=(Range<?>)object;
    if (Objects.equals(elementType,other.elementType)) {
      if (isEmpty()) {
        return other.isEmpty();
      }
      return Objects.equals(minValue,other.minValue) && Objects.equals(maxValue,other.maxValue) && isMinIncluded == other.isMinIncluded && isMaxIncluded == other.isMaxIncluded;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compares this range with the given object for equality. Two ranges are considered equal if they have the same   {@link #getElementType() element type} and:<ul> <li>are both  {@linkplain #isEmpty() empty}, or</li> <li>have equal   {@linkplain #getMinValue() minimum} and {@linkplain #getMaxValue() maximum} valueswith equal inclusive/exclusive flags.</li> </ul> Note that subclasses may add other requirements, for example on units of measurement.
 * @param object The object to compare with this range for equality.
 * @return {@code true} if the given object is equal to this range.
 */
@Override public boolean equals(final Object object){
  if (object == this) {
    return true;
  }
  if (object != null && object.getClass() == getClass()) {
    final Range<?> other=(Range<?>)object;
    if (Objects.equals(elementType,other.elementType)) {
      if (isEmpty()) {
        return other.isEmpty();
      }
      return Objects.equals(minValue,other.minValue) && Objects.equals(maxValue,other.maxValue) && isMinIncluded == other.isMinIncluded && isMaxIncluded == other.isMaxIncluded;
    }
  }
  return false;
}
Program: 91996
Project: 91996
Buggy source:
/** 
 * Returns a copy of the matrix that user can modify.
 */
@Override public final Matrix clone(){
  return Matrices.copy(this);
}

Fixed version (ground truth):
/** 
 * Returns a copy of the matrix that user can modify.
 */
@Override @SuppressWarnings("String_Node_Str") public final Matrix clone(){
  return Matrices.copy(this);
}
Program: 91997
Project: 91997
Buggy source:
/** 
 * Creates the inverse transform of this object.
 * @throws NoninvertibleTransformException if this transform can not be inverted.
 */
@Override public final MathTransform2D inverse() throws NoninvertibleTransformException {
  if (inverse == null) {
    if (super.isIdentity()) {
      inverse=this;
    }
 else synchronized (this) {
      if (inverse == null)       try {
        final AffineTransform2D work=new AffineTransform2D(this,true);
        work.invert();
        work.forcePositiveZeros();
        work.freeze();
        work.inverse=this;
        inverse=work;
      }
 catch (      java.awt.geom.NoninvertibleTransformException exception) {
        throw new NoninvertibleTransformException(exception.getLocalizedMessage(),exception);
      }
    }
  }
  return inverse;
}

Fixed version (ground truth):
/** 
 * Creates the inverse transform of this object.
 * @throws NoninvertibleTransformException if this transform can not be inverted.
 */
@Override public final MathTransform2D inverse() throws NoninvertibleTransformException {
  if (inverse == null) {
    if (super.isIdentity()) {
      inverse=this;
    }
 else synchronized (this) {
      if (inverse == null) {
        final AffineTransform2D work=new AffineTransform2D(((ExtendedPrecisionMatrix)Matrices.inverse(matrix)).getExtendedElements());
        work.inverse=this;
        inverse=work;
      }
    }
  }
  return inverse;
}
Program: 91998
Project: 91998
Buggy source:
/** 
 * Returns a new affine transform which is a modifiable copy of this transform. This implementation always returns an instance of   {@link AffineTransform}, <strong>not</strong>   {@code AffineTransform2D}, because the later is unmodifiable and cloning it make little sense.
 * @return A modifiable copy of this affine transform.
 */
@Override public AffineTransform clone(){
  return new AffineTransform(this);
}

Fixed version (ground truth):
/** 
 * Returns a new affine transform which is a modifiable copy of this transform. This implementation always returns an instance of   {@link AffineTransform}, <strong>not</strong>   {@code AffineTransform2D}, because the later is unmodifiable and cloning it make little sense.
 * @return A modifiable copy of this affine transform.
 */
@Override @SuppressWarnings("String_Node_Str") public AffineTransform clone(){
  return new AffineTransform(this);
}
Program: 91999
Project: 91999
Buggy source:
/** 
 * Constructs a new   {@code AffineTransform2D} from 6 values representing the 6 specifiableentries of the 3×3 transformation matrix. Those values are given unchanged to the {@link AffineTransform#AffineTransform(double,double,double,double,double,double) superclass constructor}.
 * @param m00 the X coordinate scaling.
 * @param m10 the Y coordinate shearing.
 * @param m01 the X coordinate shearing.
 * @param m11 the Y coordinate scaling.
 * @param m02 the X coordinate translation.
 * @param m12 the Y coordinate translation.
 */
public AffineTransform2D(double m00,double m10,double m01,double m11,double m02,double m12){
  super(pz(m00),pz(m10),pz(m01),pz(m11),pz(m02),pz(m12));
  freeze();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code AffineTransform2D} from 6 values representing the 6 specifiableentries of the 3×3 transformation matrix. Those values are given unchanged to the {@link AffineTransform#AffineTransform(double,double,double,double,double,double) superclass constructor}.
 * @param m00 the X coordinate scaling.
 * @param m10 the Y coordinate shearing.
 * @param m01 the X coordinate shearing.
 * @param m11 the Y coordinate scaling.
 * @param m02 the X coordinate translation.
 * @param m12 the Y coordinate translation.
 */
public AffineTransform2D(double m00,double m10,double m01,double m11,double m02,double m12){
  super(pz(m00),pz(m10),pz(m01),pz(m11),pz(m02),pz(m12));
  matrix=new AffineMatrix(this,null);
}
Program: 92000
Project: 92000
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public MatrixSIS clone(){
  return new GeneralMatrix(this);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override @SuppressWarnings("String_Node_Str") public MatrixSIS clone(){
  return new GeneralMatrix(this);
}
Program: 92001
Project: 92001
Buggy source:
/** 
 * Returns   {@code this} since this matrix is immutable.
 */
@Override public Matrix clone(){
  return this;
}

Fixed version (ground truth):
/** 
 * Returns   {@code this} since this matrix is immutable.
 */
@Override @SuppressWarnings("String_Node_Str") public Matrix clone(){
  return this;
}
Program: 92002
Project: 92002
Buggy source:
/** 
 * Returns an identity transform of the specified dimension. In the special case of dimension 1 and 2, this method returns instances of   {@link LinearTransform1D} or{@link AffineTransform2D} respectively.
 * @param dimension The dimension of the transform to be returned.
 * @return An identity transform of the specified dimension.
 * @see MathTransforms#identity(int)
 */
public static LinearTransform create(final int dimension){
  LinearTransform candidate;
synchronized (IDENTITIES) {
    if (dimension < IDENTITIES.length) {
      candidate=IDENTITIES[dimension];
      if (candidate != null) {
        return candidate;
      }
    }
switch (dimension) {
default :
      candidate=new IdentityTransform(dimension);
    break;
case 1:
  candidate=IdentityTransform1D.INSTANCE;
break;
case 2:
candidate=new AffineTransform2D();
((AffineTransform2D)candidate).freeze();
break;
}
if (dimension < IDENTITIES.length) {
IDENTITIES[dimension]=candidate;
}
}
return candidate;
}

Fixed version (ground truth):
/** 
 * Returns an identity transform of the specified dimension. In the special case of dimension 1 and 2, this method returns instances of   {@link LinearTransform1D} or{@link AffineTransform2D} respectively.
 * @param dimension The dimension of the transform to be returned.
 * @return An identity transform of the specified dimension.
 * @see MathTransforms#identity(int)
 */
public static LinearTransform create(final int dimension){
  LinearTransform candidate;
synchronized (IDENTITIES) {
    if (dimension < IDENTITIES.length) {
      candidate=IDENTITIES[dimension];
      if (candidate != null) {
        return candidate;
      }
    }
switch (dimension) {
default :
      candidate=new IdentityTransform(dimension);
    break;
case 1:
  candidate=IdentityTransform1D.INSTANCE;
break;
case 2:
candidate=new AffineTransform2D(1,0,0,1,0,0);
break;
}
if (dimension < IDENTITIES.length) {
IDENTITIES[dimension]=candidate;
}
}
return candidate;
}