Program: 12509
Project: 12509
Buggy source:
void copy(SequenceAnnotation sequenceAnnotation) throws SBOLValidationException {
  ((Identified)this).copy((Identified)sequenceAnnotation);
  for (  Location location : sequenceAnnotation.getLocations()) {
    if (location instanceof Range) {
      Range range=(Range)location;
      if (range.isSetOrientation()) {
        this.addRange(range.getDisplayId(),range.getStart(),range.getEnd(),range.getOrientation());
      }
 else {
        this.addRange(range.getDisplayId(),range.getStart(),range.getEnd());
      }
    }
 else     if (location instanceof Cut) {
      Cut cut=(Cut)location;
      if (cut.isSetOrientation()) {
        this.addCut(cut.getDisplayId(),cut.getAt(),cut.getOrientation());
      }
 else {
        this.addCut(cut.getDisplayId(),cut.getAt());
      }
    }
 else     if (location instanceof GenericLocation) {
      GenericLocation genericLocation=(GenericLocation)location;
      if (genericLocation.isSetOrientation()) {
        this.addGenericLocation(genericLocation.getDisplayId(),genericLocation.getOrientation());
      }
 else {
        this.addGenericLocation(genericLocation.getDisplayId());
      }
    }
  }
  Location location=this.getLocation("String_Node_Str");
  if (location != null) {
    this.removeLocation(location);
  }
  if (sequenceAnnotation.isSetComponent()) {
    this.setComponent(sequenceAnnotation.getComponentURI());
  }
  this.roles=new HashSet<>();
  for (  URI role : sequenceAnnotation.getRoles()) {
    this.addRole(URI.create(role.toString()));
  }
}

Fixed version (ground truth):
void copy(SequenceAnnotation sequenceAnnotation) throws SBOLValidationException {
  ((Identified)this).copy((Identified)sequenceAnnotation);
  for (  Location location : sequenceAnnotation.getLocations()) {
    if (location instanceof Range) {
      Range range=(Range)location;
      Range newRange;
      if (range.isSetOrientation()) {
        newRange=this.addRange(range.getDisplayId(),range.getStart(),range.getEnd(),range.getOrientation());
      }
 else {
        newRange=this.addRange(range.getDisplayId(),range.getStart(),range.getEnd());
      }
      newRange.copy(range);
    }
 else     if (location instanceof Cut) {
      Cut cut=(Cut)location;
      Cut newCut;
      if (cut.isSetOrientation()) {
        newCut=this.addCut(cut.getDisplayId(),cut.getAt(),cut.getOrientation());
      }
 else {
        newCut=this.addCut(cut.getDisplayId(),cut.getAt());
      }
      newCut.copy(cut);
    }
 else     if (location instanceof GenericLocation) {
      GenericLocation genericLocation=(GenericLocation)location;
      GenericLocation newGenericLocation;
      if (genericLocation.isSetOrientation()) {
        newGenericLocation=this.addGenericLocation(genericLocation.getDisplayId(),genericLocation.getOrientation());
      }
 else {
        newGenericLocation=this.addGenericLocation(genericLocation.getDisplayId());
      }
      newGenericLocation.copy(genericLocation);
    }
  }
  Location location=this.getLocation("String_Node_Str");
  if (location != null) {
    this.removeLocation(location);
  }
  if (sequenceAnnotation.isSetComponent()) {
    this.setComponent(sequenceAnnotation.getComponent().getDisplayId());
  }
  this.roles=new HashSet<>();
  for (  URI role : sequenceAnnotation.getRoles()) {
    this.addRole(URI.create(role.toString()));
  }
}