Program: 12367
Project: 12367
Buggy source:
/** 
 * @param SBOLDoc
 * @param topLevel
 * @param nested
 * @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, 11602, 11607 or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link #parseModule(NestedDocument,Map)},</li> <li>  {@link #parseInteraction(NestedDocument,Map)},</li> <li>  {@link #parseFunctionalComponent(NestedDocument,Map)},</li>	 <li>  {@link ModuleDefinition#ModuleDefinition(URI)}, </li> <li>  {@link ModuleDefinition#setDisplayId(String)}, </li> <li>  {@link ModuleDefinition#setVersion(String)}, </li> <li>  {@link ModuleDefinition#setFunctionalComponents(Set)}, </li> <li>  {@link ModuleDefinition#setInteractions(Set)}, </li> <li>  {@link ModuleDefinition#setModels(Set)}, </li> <li>  {@link ModuleDefinition#setModules(Set)}, </li> <li>  {@link ModuleDefinition#setWasDerivedFrom(URI)}, </li> <li>  {@link ModuleDefinition#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addModuleDefinition(ModuleDefinition)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings("String_Node_Str") private static ModuleDefinition parseModuleDefinition(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> roles=new HashSet<>();
  Set<URI> models=new HashSet<>();
  Set<FunctionalComponent> functionalComponents=new HashSet<>();
  Set<Interaction> interactions=new HashSet<>();
  Set<Module> subModules=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.ModuleDefinition.roles)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      roles.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModule) || namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasSubModule)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Module.Module)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        subModules.add(parseModule(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.Module.Module)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        subModules.add(parseModule(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasInteractions)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Interaction.Interaction)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        interactions.add(parseInteraction((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.Interaction.Interaction)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        interactions.add(parseInteraction(nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasfunctionalComponent) || namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasComponent)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.FunctionalComponent.FunctionalComponent)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        functionalComponents.add(parseFunctionalComponent(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.FunctionalComponent.FunctionalComponent)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        functionalComponents.add(parseFunctionalComponent(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModels)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        models.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Model.Model)) {
          Model model=parseModel(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          models.add(model.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.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));
    }
  }
  ModuleDefinition moduleDefinition=new ModuleDefinition(topLevel.getIdentity());
  if (!roles.isEmpty())   moduleDefinition.setRoles(roles);
  if (persistentIdentity != null)   moduleDefinition.setPersistentIdentity(persistentIdentity);
  if (version != null)   moduleDefinition.setVersion(version);
  if (displayId != null)   moduleDefinition.setDisplayId(displayId);
  if (!functionalComponents.isEmpty())   moduleDefinition.setFunctionalComponents(functionalComponents);
  if (!interactions.isEmpty())   moduleDefinition.setInteractions(interactions);
  if (!models.isEmpty())   moduleDefinition.setModels(models);
  if (!subModules.isEmpty())   moduleDefinition.setModules(subModules);
  if (name != null)   moduleDefinition.setName(name);
  if (description != null)   moduleDefinition.setDescription(description);
  moduleDefinition.setWasDerivedFroms(wasDerivedFroms);
  moduleDefinition.setWasGeneratedBys(wasGeneratedBys);
  if (!annotations.isEmpty())   moduleDefinition.setAnnotations(annotations);
  ModuleDefinition oldM=SBOLDoc.getModuleDefinition(topLevel.getIdentity());
  if (oldM == null) {
    SBOLDoc.addModuleDefinition(moduleDefinition);
  }
 else {
    if (!moduleDefinition.equals(oldM)) {
      throw new SBOLValidationException("String_Node_Str",moduleDefinition);
    }
  }
  return moduleDefinition;
}

Fixed version (ground truth):
/** 
 * @param SBOLDoc
 * @param topLevel
 * @param nested
 * @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, 11602, 11607 or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link #parseModule(NestedDocument,Map)},</li> <li>  {@link #parseInteraction(NestedDocument,Map)},</li> <li>  {@link #parseFunctionalComponent(NestedDocument,Map)},</li>	 <li>  {@link ModuleDefinition#ModuleDefinition(URI)}, </li> <li>  {@link ModuleDefinition#setDisplayId(String)}, </li> <li>  {@link ModuleDefinition#setVersion(String)}, </li> <li>  {@link ModuleDefinition#setFunctionalComponents(Set)}, </li> <li>  {@link ModuleDefinition#setInteractions(Set)}, </li> <li>  {@link ModuleDefinition#setModels(Set)}, </li> <li>  {@link ModuleDefinition#setModules(Set)}, </li> <li>  {@link ModuleDefinition#setWasDerivedFrom(URI)}, </li> <li>  {@link ModuleDefinition#setAnnotations(List)}, or</li> <li>  {@link SBOLDocument#addModuleDefinition(ModuleDefinition)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings("String_Node_Str") private static ModuleDefinition parseModuleDefinition(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> roles=new HashSet<>();
  Set<URI> models=new HashSet<>();
  Set<FunctionalComponent> functionalComponents=new HashSet<>();
  Set<Interaction> interactions=new HashSet<>();
  Set<Module> subModules=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.ModuleDefinition.roles)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      roles.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModule) || namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasSubModule)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Module.Module)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        subModules.add(parseModule(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.Module.Module)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        subModules.add(parseModule(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasInteractions)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Interaction.Interaction)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        interactions.add(parseInteraction((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.Interaction.Interaction)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        interactions.add(parseInteraction(nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasfunctionalComponent) || namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasComponent)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.FunctionalComponent.FunctionalComponent)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        functionalComponents.add(parseFunctionalComponent(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.FunctionalComponent.FunctionalComponent)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        functionalComponents.add(parseFunctionalComponent(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModels)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        models.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Model.Model)) {
          Model model=parseModel(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          models.add(model.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.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));
    }
  }
  ModuleDefinition moduleDefinition=new ModuleDefinition(topLevel.getIdentity());
  if (!roles.isEmpty())   moduleDefinition.setRoles(roles);
  if (persistentIdentity != null)   moduleDefinition.setPersistentIdentity(persistentIdentity);
  if (version != null)   moduleDefinition.setVersion(version);
  if (displayId != null)   moduleDefinition.setDisplayId(displayId);
  if (!functionalComponents.isEmpty())   moduleDefinition.setFunctionalComponents(functionalComponents);
  if (!interactions.isEmpty())   moduleDefinition.setInteractions(interactions);
  if (!models.isEmpty())   moduleDefinition.setModels(models);
  if (!subModules.isEmpty())   moduleDefinition.setModules(subModules);
  if (name != null)   moduleDefinition.setName(name);
  if (description != null)   moduleDefinition.setDescription(description);
  moduleDefinition.setWasDerivedFroms(wasDerivedFroms);
  moduleDefinition.setWasGeneratedBys(wasGeneratedBys);
  moduleDefinition.setAttachments(attachments);
  if (!annotations.isEmpty())   moduleDefinition.setAnnotations(annotations);
  ModuleDefinition oldM=SBOLDoc.getModuleDefinition(topLevel.getIdentity());
  if (oldM == null) {
    SBOLDoc.addModuleDefinition(moduleDefinition);
  }
 else {
    if (!moduleDefinition.equals(oldM)) {
      throw new SBOLValidationException("String_Node_Str",moduleDefinition);
    }
  }
  return moduleDefinition;
}