Program: 12472
Project: 12472
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 GenericTopLevel#GenericTopLevel(URI,QName)}, </li> <li>  {@link GenericTopLevel#setDisplayId(String)}, </li> <li>  {@link GenericTopLevel#setVersion(String)}, </li> <li>  {@link GenericTopLevel#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addGenericTopLevel(GenericTopLevel)}.</li> </ul> </li> </ul>
 */
private static GenericTopLevel parseGenericTopLevel(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel) throws SBOLValidationException {
  String displayId=null;
  String name=null;
  String description=null;
  URI persistentIdentity=null;
  String version=null;
  URI wasDerivedFrom=null;
  QName type=topLevel.getType();
  List<Annotation> annotations=new ArrayList<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol2Terms.Description.type)) {
      String typeStr=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      String nameSpace=URIcompliance.extractURIprefix(URI.create(typeStr)) + "String_Node_Str";
      String localPart=URIcompliance.extractDisplayId(URI.create(typeStr));
      String prefix=SBOLDoc.getNamespace(URI.create(nameSpace)).getPrefix();
      type=new QName(nameSpace,localPart,prefix);
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((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) || (!(((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) || (!(((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) || (!(((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) || (!(((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());
      }
      wasDerivedFrom=URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  GenericTopLevel t=new GenericTopLevel(topLevel.getIdentity(),type);
  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);
  if (wasDerivedFrom != null)   t.setWasDerivedFrom(wasDerivedFrom);
  if (!annotations.isEmpty())   t.setAnnotations(annotations);
  GenericTopLevel oldG=SBOLDoc.getGenericTopLevel(topLevel.getIdentity());
  if (oldG == null) {
    SBOLDoc.addGenericTopLevel(t);
  }
 else {
    if (!t.equals(oldG)) {
      throw new SBOLValidationException("String_Node_Str",t);
    }
  }
  return t;
}

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 GenericTopLevel#GenericTopLevel(URI,QName)}, </li> <li>  {@link GenericTopLevel#setDisplayId(String)}, </li> <li>  {@link GenericTopLevel#setVersion(String)}, </li> <li>  {@link GenericTopLevel#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addGenericTopLevel(GenericTopLevel)}.</li> </ul> </li> </ul>
 */
private static GenericTopLevel parseGenericTopLevel(SBOLDocument SBOLDoc,IdentifiableDocument<QName> topLevel) throws SBOLValidationException {
  String displayId=null;
  String name=null;
  String description=null;
  URI persistentIdentity=null;
  String version=null;
  URI wasDerivedFrom=null;
  QName type=topLevel.getType();
  List<Annotation> annotations=new ArrayList<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    if (namedProperty.getName().equals(Sbol2Terms.Description.type)) {
      String typeStr=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      String nameSpace=URIcompliance.extractNamespace(URI.create(typeStr));
      String localPart=URIcompliance.extractDisplayId(URI.create(typeStr));
      String prefix=SBOLDoc.getNamespace(URI.create(nameSpace)).getPrefix();
      type=new QName(nameSpace,localPart,prefix);
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((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) || (!(((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) || (!(((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) || (!(((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) || (!(((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());
      }
      wasDerivedFrom=URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  GenericTopLevel t=new GenericTopLevel(topLevel.getIdentity(),type);
  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);
  if (wasDerivedFrom != null)   t.setWasDerivedFrom(wasDerivedFrom);
  if (!annotations.isEmpty())   t.setAnnotations(annotations);
  GenericTopLevel oldG=SBOLDoc.getGenericTopLevel(topLevel.getIdentity());
  if (oldG == null) {
    SBOLDoc.addGenericTopLevel(t);
  }
 else {
    if (!t.equals(oldG)) {
      throw new SBOLValidationException("String_Node_Str",t);
    }
  }
  return t;
}