Program: 12371
Project: 12371
Buggy source:
@SuppressWarnings("String_Node_Str") private static Agent parseAgent(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel) throws SBOLValidationException {
  String displayId=null;
  String name=null;
  String description=null;
  URI persistentIdentity=null;
  String version=null;
  Set<URI> wasDerivedFroms=new HashSet<>();
  Set<URI> wasGeneratedBys=new HashSet<>();
  Set<URI> attachments=new HashSet<>();
  List<Annotation> annotations=new ArrayList<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
      if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      persistentIdentity=URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
      if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      version=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
      if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
      if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
      if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      wasDerivedFroms.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      wasGeneratedBys.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.TopLevel.hasAttachment)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        attachments.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Attachment.Attachment)) {
          Attachment attachment=parseAttachment(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          attachments.add(attachment.getIdentity());
        }
 else {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Agent t=new Agent(topLevel.getIdentity());
  if (persistentIdentity != null)   t.setPersistentIdentity(persistentIdentity);
  if (version != null)   t.setVersion(version);
  if (displayId != null)   t.setDisplayId(displayId);
  if (name != null)   t.setName(name);
  if (description != null)   t.setDescription(description);
  t.setWasDerivedFroms(wasDerivedFroms);
  t.setWasGeneratedBys(wasGeneratedBys);
  if (!annotations.isEmpty())   t.setAnnotations(annotations);
  Agent oldA=SBOLDoc.getAgent(topLevel.getIdentity());
  if (oldA == null) {
    SBOLDoc.addAgent(t);
  }
 else {
    if (!t.equals(oldA)) {
      throw new SBOLValidationException("String_Node_Str",t);
    }
  }
  return t;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static Agent parseAgent(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel) throws SBOLValidationException {
  String displayId=null;
  String name=null;
  String description=null;
  URI persistentIdentity=null;
  String version=null;
  Set<URI> wasDerivedFroms=new HashSet<>();
  Set<URI> wasGeneratedBys=new HashSet<>();
  Set<URI> attachments=new HashSet<>();
  List<Annotation> annotations=new ArrayList<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
      if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      persistentIdentity=URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
      if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      version=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
      if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
      if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
      if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      wasDerivedFroms.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      wasGeneratedBys.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.TopLevel.hasAttachment)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        attachments.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Attachment.Attachment)) {
          Attachment attachment=parseAttachment(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          attachments.add(attachment.getIdentity());
        }
 else {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Agent t=new Agent(topLevel.getIdentity());
  if (persistentIdentity != null)   t.setPersistentIdentity(persistentIdentity);
  if (version != null)   t.setVersion(version);
  if (displayId != null)   t.setDisplayId(displayId);
  if (name != null)   t.setName(name);
  if (description != null)   t.setDescription(description);
  t.setWasDerivedFroms(wasDerivedFroms);
  t.setWasGeneratedBys(wasGeneratedBys);
  t.setAttachments(attachments);
  if (!annotations.isEmpty())   t.setAnnotations(annotations);
  Agent oldA=SBOLDoc.getAgent(topLevel.getIdentity());
  if (oldA == null) {
    SBOLDoc.addAgent(t);
  }
 else {
    if (!t.equals(oldA)) {
      throw new SBOLValidationException("String_Node_Str",t);
    }
  }
  return t;
}