Program: 12377
Project: 12377
Buggy source:
@SuppressWarnings("String_Node_Str") private static Activity parseActivity(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<>();
  DateTime startedAtTime=null;
  DateTime endedAtTime=null;
  Set<URI> wasInformedBys=new HashSet<>();
  Set<Association> qualifiedAssociations=new HashSet<>();
  Set<Usage> qualifiedUsages=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     if (namedProperty.getName().equals(Sbol2Terms.Activity.startedAtTime)) {
      if (!(namedProperty.getValue() instanceof Literal) || startedAtTime != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      DateTimeFormatter fmt=ISODateTimeFormat.dateTime();
      startedAtTime=fmt.parseDateTime(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.endedAtTime)) {
      if (!(namedProperty.getValue() instanceof Literal) || endedAtTime != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      DateTimeFormatter fmt=ISODateTimeFormat.dateTime();
      endedAtTime=fmt.parseDateTime(((Literal<QName>)namedProperty.getValue()).getValue().toString());
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.wasInformedBy)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        wasInformedBys.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Activity.Activity)) {
          Activity activity=parseActivity(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue(),nested);
          wasInformedBys.add(activity.getIdentity());
        }
 else {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.qualifiedAssociation)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Association.Association)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedAssociations.add(parseAssociation(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),nested));
      }
 else {
        URI uri=(URI)((Literal<QName>)namedProperty.getValue()).getValue();
        NestedDocument<QName> nestedDocument=nested.get(uri);
        if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Association.Association)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedAssociations.add(parseAssociation(SBOLDoc,nestedDocument,nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.qualifiedUsage)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Usage.Usage)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedUsages.add(parseUsage(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),nested));
      }
 else {
        URI uri=(URI)((Literal<QName>)namedProperty.getValue()).getValue();
        NestedDocument<QName> nestedDocument=nested.get(uri);
        if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Usage.Usage)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedUsages.add(parseUsage(SBOLDoc,nestedDocument,nested));
      }
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Activity t=new Activity(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);
  if (startedAtTime != null)   t.setStartedAtTime(startedAtTime);
  if (endedAtTime != null)   t.setEndedAtTime(endedAtTime);
  if (!qualifiedAssociations.isEmpty())   t.setAssociations(qualifiedAssociations);
  if (!qualifiedUsages.isEmpty())   t.setUsages(qualifiedUsages);
  if (!wasInformedBys.isEmpty())   t.setWasInformedBys(wasInformedBys);
  if (!attachments.isEmpty())   t.setAttachments(attachments);
  Activity oldA=SBOLDoc.getActivity(topLevel.getIdentity());
  if (oldA == null) {
    SBOLDoc.addActivity(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 Activity parseActivity(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<>();
  DateTime startedAtTime=null;
  DateTime endedAtTime=null;
  Set<URI> wasInformedBys=new HashSet<>();
  Set<Association> qualifiedAssociations=new HashSet<>();
  Set<Usage> qualifiedUsages=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     if (namedProperty.getName().equals(Sbol2Terms.Activity.startedAtTime)) {
      if (!(namedProperty.getValue() instanceof Literal) || startedAtTime != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      DateTimeFormatter fmt=ISODateTimeFormat.dateTime();
      try {
        startedAtTime=fmt.parseDateTime(((Literal<QName>)namedProperty.getValue()).getValue().toString());
      }
 catch (      IllegalArgumentException e) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.endedAtTime)) {
      if (!(namedProperty.getValue() instanceof Literal) || endedAtTime != null || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof String))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      DateTimeFormatter fmt=ISODateTimeFormat.dateTime();
      try {
        endedAtTime=fmt.parseDateTime(((Literal<QName>)namedProperty.getValue()).getValue().toString());
      }
 catch (      IllegalArgumentException e) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.wasInformedBy)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        wasInformedBys.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Activity.Activity)) {
          Activity activity=parseActivity(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue(),nested);
          wasInformedBys.add(activity.getIdentity());
        }
 else {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
      }
 else {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.qualifiedAssociation)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Association.Association)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedAssociations.add(parseAssociation(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),nested));
      }
 else {
        URI uri=(URI)((Literal<QName>)namedProperty.getValue()).getValue();
        NestedDocument<QName> nestedDocument=nested.get(uri);
        if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Association.Association)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedAssociations.add(parseAssociation(SBOLDoc,nestedDocument,nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.Activity.qualifiedUsage)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Usage.Usage)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedUsages.add(parseUsage(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),nested));
      }
 else {
        URI uri=(URI)((Literal<QName>)namedProperty.getValue()).getValue();
        NestedDocument<QName> nestedDocument=nested.get(uri);
        if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Usage.Usage)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        qualifiedUsages.add(parseUsage(SBOLDoc,nestedDocument,nested));
      }
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  Activity t=new Activity(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);
  if (startedAtTime != null)   t.setStartedAtTime(startedAtTime);
  if (endedAtTime != null)   t.setEndedAtTime(endedAtTime);
  if (!qualifiedAssociations.isEmpty())   t.setAssociations(qualifiedAssociations);
  if (!qualifiedUsages.isEmpty())   t.setUsages(qualifiedUsages);
  if (!wasInformedBys.isEmpty())   t.setWasInformedBys(wasInformedBys);
  if (!attachments.isEmpty())   t.setAttachments(attachments);
  Activity oldA=SBOLDoc.getActivity(topLevel.getIdentity());
  if (oldA == null) {
    SBOLDoc.addActivity(t);
  }
 else {
    if (!t.equals(oldA)) {
      throw new SBOLValidationException("String_Node_Str",t);
    }
  }
  return t;
}