Program: 12369
Project: 12369
Buggy source:
/** 
 * @param SBOLDoc
 * @param topLevel
 * @return
 * @throws SBOLValidationException if either of the following conditions is satisfied:<ul> <li>any of the following SBOL validation rules was violated:  10202, 10203, 10204, 10206, 10208, 10212, 10213, 12102; or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link Collection#Collection(URI)}, </li> <li>  {@link Collection#setDisplayId(String)}, </li> <li>  {@link Collection#setVersion(String)}, </li> <li>  {@link Collection#setMembers(Set)}, </li> <li>  {@link Collection#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addCollection(Collection)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) private static Collection parseCollection(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel,Map<URI,NestedDocument<QName>> nested) 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<>();
  Set<URI> members=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.Collection.hasMembers)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        members.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof NestedDocument) {
        if (((IdentifiableDocument)namedProperty).getType().equals(Sbol2Terms.Collection.Collection))         parseCollection(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.ModuleDefinition.ModuleDefinition))         parseModuleDefinition(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Model.Model))         parseModel(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Sequence.Sequence))         parseSequence(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.ComponentDefinition.ComponentDefinition))         parseComponentDefinition(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.CombinatorialDerivation.CombinatorialDerivation))         parseCombinatorialDerivation(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Implementation.Implementation))         parseImplementation(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Attachment.Attachment))         parseAttachment(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Activity.Activity))         parseActivity(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Agent.Agent))         parseAgent(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Plan.Plan))         parsePlan(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         parseGenericTopLevel(SBOLDoc,(IdentifiableDocument)namedProperty);
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 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));
    }
  }
  Collection c=new Collection(topLevel.getIdentity());
  if (displayId != null)   c.setDisplayId(displayId);
  if (version != null)   c.setVersion(version);
  if (persistentIdentity != null)   c.setPersistentIdentity(persistentIdentity);
  if (!members.isEmpty())   c.setMembers(members);
  if (name != null)   c.setName(name);
  if (description != null)   c.setDescription(description);
  c.setWasDerivedFroms(wasDerivedFroms);
  c.setWasGeneratedBys(wasGeneratedBys);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  Collection oldC=SBOLDoc.getCollection(topLevel.getIdentity());
  if (oldC == null) {
    SBOLDoc.addCollection(c);
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str",c);
    }
  }
  return c;
}

Fixed version (ground truth):
/** 
 * @param SBOLDoc
 * @param topLevel
 * @return
 * @throws SBOLValidationException if either of the following conditions is satisfied:<ul> <li>any of the following SBOL validation rules was violated:  10202, 10203, 10204, 10206, 10208, 10212, 10213, 12102; or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link Collection#Collection(URI)}, </li> <li>  {@link Collection#setDisplayId(String)}, </li> <li>  {@link Collection#setVersion(String)}, </li> <li>  {@link Collection#setMembers(Set)}, </li> <li>  {@link Collection#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addCollection(Collection)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) private static Collection parseCollection(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel,Map<URI,NestedDocument<QName>> nested) 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<>();
  Set<URI> members=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.Collection.hasMembers)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        members.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof NestedDocument) {
        if (((IdentifiableDocument)namedProperty).getType().equals(Sbol2Terms.Collection.Collection))         parseCollection(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.ModuleDefinition.ModuleDefinition))         parseModuleDefinition(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Model.Model))         parseModel(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Sequence.Sequence))         parseSequence(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.ComponentDefinition.ComponentDefinition))         parseComponentDefinition(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.CombinatorialDerivation.CombinatorialDerivation))         parseCombinatorialDerivation(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Implementation.Implementation))         parseImplementation(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Attachment.Attachment))         parseAttachment(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Activity.Activity))         parseActivity(SBOLDoc,(IdentifiableDocument)namedProperty,nested);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Agent.Agent))         parseAgent(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         if (((IdentifiableDocument)namedProperty).equals(Sbol2Terms.Plan.Plan))         parsePlan(SBOLDoc,(IdentifiableDocument)namedProperty);
 else         parseGenericTopLevel(SBOLDoc,(IdentifiableDocument)namedProperty);
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 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));
    }
  }
  Collection c=new Collection(topLevel.getIdentity());
  if (displayId != null)   c.setDisplayId(displayId);
  if (version != null)   c.setVersion(version);
  if (persistentIdentity != null)   c.setPersistentIdentity(persistentIdentity);
  if (!members.isEmpty())   c.setMembers(members);
  if (name != null)   c.setName(name);
  if (description != null)   c.setDescription(description);
  c.setWasDerivedFroms(wasDerivedFroms);
  c.setWasGeneratedBys(wasGeneratedBys);
  c.setAttachments(attachments);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  Collection oldC=SBOLDoc.getCollection(topLevel.getIdentity());
  if (oldC == null) {
    SBOLDoc.addCollection(c);
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str",c);
    }
  }
  return c;
}