Program: 12665
Project: 12665
Buggy source:
private static ComponentDefinition parseDnaComponentV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> componentDef){
  String displayId=null;
  String name=null;
  String description=null;
  URI seq_identity=null;
  Set<URI> roles=new HashSet<>();
  URI identity=componentDef.getIdentity();
  String persIdentity="String_Node_Str";
  List<Annotation> annotations=new ArrayList<>();
  List<SequenceAnnotation> sequenceAnnotations=new ArrayList<>();
  List<Component> components=new ArrayList<>();
  List<SequenceConstraint> sequenceConstraints=new ArrayList<>();
  List<SBOLPair> precedePairs=new ArrayList<>();
  Map<URI,URI> componentDefMap=new HashMap<>();
  Set<URI> type=new HashSet<>();
  type.add(Sbol2Terms.DnaComponentV1URI.type);
  int component_num=0;
  int sa_num=0;
  for (  NamedProperty<QName> namedProperty : componentDef.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      displayId=fixDisplayId(displayId);
      if (URIPrefix != null) {
        persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
        identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.name)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.type)) {
      roles.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.annotations)) {
      SequenceAnnotation sa=parseSequenceAnnotationV1(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),precedePairs,persIdentity,++sa_num);
      sequenceAnnotations.add(sa);
      URI component_identity=createCompliantURI(persIdentity,"String_Node_Str" + ++component_num,version);
      AccessType access=AccessType.PUBLIC;
      URI instantiatedComponent=sa.getComponentURI();
      URI originalURI=((NestedDocument<QName>)namedProperty.getValue()).getIdentity();
      componentDefMap.put(originalURI,component_identity);
      sa.setComponent(component_identity);
      Component component=new Component(component_identity,access,instantiatedComponent);
      if (!persIdentity.equals("String_Node_Str")) {
        component.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + ++component_num,"String_Node_Str"));
        component.setDisplayId("String_Node_Str" + component_num);
        component.setVersion(version);
      }
      components.add(component);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.dnaSequence)) {
      seq_identity=parseDnaSequenceV1(SBOLDoc,(NestedDocument<QName>)namedProperty.getValue()).getIdentity();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  if (roles.isEmpty())   roles.add(Sbol2Terms.DnaComponentV1URI.roles);
  int sc_number=0;
  for (  SBOLPair pair : precedePairs) {
    URI sc_identity=createCompliantURI(persIdentity,"String_Node_Str" + ++sc_number,version);
    URI restrictionURI=RestrictionType.convertToURI(RestrictionType.PRECEDES);
    URI subject=null;
    URI object=null;
    for (    URI key : componentDefMap.keySet()) {
      if (pair.getLeft().equals(key)) {
        subject=componentDefMap.get(key);
      }
 else       if (pair.getRight().equals(key)) {
        object=componentDefMap.get(key);
      }
    }
    SequenceConstraint sc=new SequenceConstraint(sc_identity,restrictionURI,subject,object);
    if (!persIdentity.equals("String_Node_Str")) {
      sc.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + sc_number,version));
      sc.setDisplayId("String_Node_Str" + sc_number);
      sc.setVersion(version);
    }
    sequenceConstraints.add(sc);
  }
  ComponentDefinition c=SBOLDoc.getComponentDefinition(identity);
  if (c == null) {
    c=SBOLDoc.createComponentDefinition(identity,type);
    if (!persIdentity.equals("String_Node_Str")) {
      c.setPersistentIdentity(URI.create(persIdentity));
      c.setVersion(version);
    }
    if (roles != null)     c.setRoles(roles);
    if (identity != componentDef.getIdentity())     c.setWasDerivedFrom(componentDef.getIdentity());
    if (displayId != null)     c.setDisplayId(displayId);
    if (name != null && !name.isEmpty())     c.setName(name);
    if (description != null && !description.isEmpty())     c.setDescription(description);
    if (seq_identity != null)     c.addSequence(seq_identity);
    if (!annotations.isEmpty())     c.setAnnotations(annotations);
    if (!sequenceAnnotations.isEmpty())     c.setSequenceAnnotations(sequenceAnnotations);
    if (!components.isEmpty())     c.setComponents(components);
    if (!sequenceConstraints.isEmpty())     c.setSequenceConstraints(sequenceConstraints);
  }
  return c;
}

Fixed version (ground truth):
private static ComponentDefinition parseDnaComponentV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> componentDef){
  String displayId=null;
  String name=null;
  String description=null;
  URI seq_identity=null;
  Set<URI> roles=new HashSet<>();
  URI identity=componentDef.getIdentity();
  String persIdentity="String_Node_Str";
  List<Annotation> annotations=new ArrayList<>();
  List<SequenceAnnotation> sequenceAnnotations=new ArrayList<>();
  List<Component> components=new ArrayList<>();
  List<SequenceConstraint> sequenceConstraints=new ArrayList<>();
  List<SBOLPair> precedePairs=new ArrayList<>();
  Map<URI,URI> componentDefMap=new HashMap<>();
  Set<URI> type=new HashSet<>();
  type.add(Sbol2Terms.DnaComponentV1URI.type);
  int component_num=0;
  int sa_num=0;
  for (  NamedProperty<QName> namedProperty : componentDef.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      displayId=fixDisplayId(displayId);
      if (URIPrefix != null) {
        persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
        identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.name)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.type)) {
      roles.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.annotations)) {
      SequenceAnnotation sa=parseSequenceAnnotationV1(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),precedePairs,persIdentity,++sa_num);
      sequenceAnnotations.add(sa);
      URI component_identity=createCompliantURI(persIdentity,"String_Node_Str" + component_num,version);
      AccessType access=AccessType.PUBLIC;
      URI instantiatedComponent=sa.getComponentURI();
      URI originalURI=((NestedDocument<QName>)namedProperty.getValue()).getIdentity();
      componentDefMap.put(originalURI,component_identity);
      sa.setComponent(component_identity);
      Component component=new Component(component_identity,access,instantiatedComponent);
      if (!persIdentity.equals("String_Node_Str")) {
        component.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + component_num,"String_Node_Str"));
        component.setDisplayId("String_Node_Str" + component_num);
        component.setVersion(version);
      }
      component_num++;
      components.add(component);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.dnaSequence)) {
      seq_identity=parseDnaSequenceV1(SBOLDoc,(NestedDocument<QName>)namedProperty.getValue()).getIdentity();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  if (roles.isEmpty())   roles.add(Sbol2Terms.DnaComponentV1URI.roles);
  int sc_number=0;
  for (  SBOLPair pair : precedePairs) {
    URI sc_identity=createCompliantURI(persIdentity,"String_Node_Str" + ++sc_number,version);
    URI restrictionURI=RestrictionType.convertToURI(RestrictionType.PRECEDES);
    URI subject=null;
    URI object=null;
    for (    URI key : componentDefMap.keySet()) {
      if (pair.getLeft().equals(key)) {
        subject=componentDefMap.get(key);
      }
 else       if (pair.getRight().equals(key)) {
        object=componentDefMap.get(key);
      }
    }
    SequenceConstraint sc=new SequenceConstraint(sc_identity,restrictionURI,subject,object);
    if (!persIdentity.equals("String_Node_Str")) {
      sc.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + sc_number,version));
      sc.setDisplayId("String_Node_Str" + sc_number);
      sc.setVersion(version);
    }
    sequenceConstraints.add(sc);
  }
  ComponentDefinition c=SBOLDoc.getComponentDefinition(identity);
  if (c == null) {
    c=SBOLDoc.createComponentDefinition(identity,type);
    if (!persIdentity.equals("String_Node_Str")) {
      c.setPersistentIdentity(URI.create(persIdentity));
      c.setVersion(version);
    }
    if (roles != null)     c.setRoles(roles);
    if (identity != componentDef.getIdentity())     c.setWasDerivedFrom(componentDef.getIdentity());
    if (displayId != null)     c.setDisplayId(displayId);
    if (name != null && !name.isEmpty())     c.setName(name);
    if (description != null && !description.isEmpty())     c.setDescription(description);
    if (seq_identity != null)     c.addSequence(seq_identity);
    if (!annotations.isEmpty())     c.setAnnotations(annotations);
    if (!sequenceAnnotations.isEmpty())     c.setSequenceAnnotations(sequenceAnnotations);
    if (!components.isEmpty())     c.setComponents(components);
    if (!sequenceConstraints.isEmpty())     c.setSequenceConstraints(sequenceConstraints);
  }
  return c;
}