Program: 12375
Project: 12375
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, 10502, 10507, 10512, or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link #parseComponent(NestedDocument,Map)},</li> <li>  {@link #parseSequenceAnnotation(NestedDocument,Map)},</li> <li>  {@link ComponentDefinition#ComponentDefinition(URI,Set)}, </li> <li>  {@link ComponentDefinition#setDisplayId(String)}, </li> <li>  {@link ComponentDefinition#setVersion(String)}, </li> <li>  {@link ComponentDefinition#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)},</li> <li>  {@link ComponentDefinition#setComponents(Set)},</li> <li>  {@link ComponentDefinition#setSequenceAnnotations(Set)},</li> <li>  {@link ComponentDefinition#setSequenceConstraints(Set)}, or</li> <li>  {@link SBOLDocument#addComponentDefinition(ComponentDefinition)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings("String_Node_Str") private static ComponentDefinition parseComponentDefinition(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> type=new HashSet<>();
  Set<URI> roles=new HashSet<>();
  Set<URI> sequences=new HashSet<>();
  Set<Component> components=new HashSet<>();
  List<Annotation> annotations=new ArrayList<>();
  Set<SequenceAnnotation> sequenceAnnotations=new HashSet<>();
  Set<SequenceConstraint> sequenceConstraints=new HashSet<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    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.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.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.ComponentDefinition.type)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      type.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.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.ComponentDefinition.hasComponent) || namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSubComponent)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Component.Component)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        components.add(parseComponent(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.Component.Component)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        components.add(parseComponent(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSequence)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequences.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Sequence.Sequence)) {
          Sequence sequence=parseSequence(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          sequences.add(sequence.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.ComponentDefinition.hasSequenceAnnotations)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.SequenceAnnotation.SequenceAnnotation)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceAnnotations.add(parseSequenceAnnotation(((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.SequenceAnnotation.SequenceAnnotation)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceAnnotations.add(parseSequenceAnnotation(nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSequenceConstraints)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.SequenceConstraint.SequenceConstraint)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceConstraints.add(parseSequenceConstraint(((NestedDocument<QName>)namedProperty.getValue())));
      }
 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.SequenceConstraint.SequenceConstraint)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceConstraints.add(parseSequenceConstraint(nested.get(uri)));
      }
    }
 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));
    }
  }
  ComponentDefinition c=new ComponentDefinition(topLevel.getIdentity(),type);
  if (roles != null)   c.setRoles(roles);
  if (displayId != null)   c.setDisplayId(displayId);
  if (persistentIdentity != null)   c.setPersistentIdentity(persistentIdentity);
  if (!sequences.isEmpty())   c.setSequences(sequences);
  if (!components.isEmpty())   c.setComponents(components);
  if (!sequenceAnnotations.isEmpty())   c.setSequenceAnnotations(sequenceAnnotations);
  if (!sequenceConstraints.isEmpty())   c.setSequenceConstraints(sequenceConstraints);
  if (name != null)   c.setName(name);
  if (description != null)   c.setDescription(description);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  if (version != null)   c.setVersion(version);
  c.setWasDerivedFroms(wasDerivedFroms);
  c.setWasGeneratedBys(wasGeneratedBys);
  ComponentDefinition oldC=SBOLDoc.getComponentDefinition(topLevel.getIdentity());
  if (oldC == null) {
    SBOLDoc.addComponentDefinition(c);
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str",c);
    }
  }
  return c;
}

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, 10502, 10507, 10512, or</li> <li>an SBOL validation rule violation occurred in the following constructor or methods: <ul> <li> {@link #parseComponent(NestedDocument,Map)},</li> <li>  {@link #parseSequenceAnnotation(NestedDocument,Map)},</li> <li>  {@link ComponentDefinition#ComponentDefinition(URI,Set)}, </li> <li>  {@link ComponentDefinition#setDisplayId(String)}, </li> <li>  {@link ComponentDefinition#setVersion(String)}, </li> <li>  {@link ComponentDefinition#setWasDerivedFrom(URI)}, </li> <li>  {@link Identified#setAnnotations(List)},</li> <li>  {@link ComponentDefinition#setComponents(Set)},</li> <li>  {@link ComponentDefinition#setSequenceAnnotations(Set)},</li> <li>  {@link ComponentDefinition#setSequenceConstraints(Set)}, or</li> <li>  {@link SBOLDocument#addComponentDefinition(ComponentDefinition)}.</li> </ul> </li> </ul>
 */
@SuppressWarnings("String_Node_Str") private static ComponentDefinition parseComponentDefinition(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> type=new HashSet<>();
  Set<URI> roles=new HashSet<>();
  Set<URI> sequences=new HashSet<>();
  Set<Component> components=new HashSet<>();
  List<Annotation> annotations=new ArrayList<>();
  Set<SequenceAnnotation> sequenceAnnotations=new HashSet<>();
  Set<SequenceConstraint> sequenceConstraints=new HashSet<>();
  for (  NamedProperty<QName> namedProperty : topLevel.getProperties()) {
    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.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.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.ComponentDefinition.type)) {
      if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI))) {
        throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
      }
      type.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.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.ComponentDefinition.hasComponent) || namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSubComponent)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Component.Component)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        components.add(parseComponent(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.Component.Component)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        components.add(parseComponent(SBOLDoc,nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSequence)) {
      if (namedProperty.getValue() instanceof Literal) {
        if (!(((Literal<QName>)namedProperty.getValue()).getValue() instanceof URI)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequences.add(URI.create(((Literal<QName>)namedProperty.getValue()).getValue().toString()));
      }
 else       if (namedProperty.getValue() instanceof IdentifiableDocument) {
        if (((IdentifiableDocument<QName>)namedProperty).getType().equals(Sbol2Terms.Sequence.Sequence)) {
          Sequence sequence=parseSequence(SBOLDoc,(IdentifiableDocument<QName>)namedProperty.getValue());
          sequences.add(sequence.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.ComponentDefinition.hasSequenceAnnotations)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.SequenceAnnotation.SequenceAnnotation)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceAnnotations.add(parseSequenceAnnotation(((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.SequenceAnnotation.SequenceAnnotation)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceAnnotations.add(parseSequenceAnnotation(nested.get(uri),nested));
      }
    }
 else     if (namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasSequenceConstraints)) {
      if (namedProperty.getValue() instanceof NestedDocument) {
        NestedDocument<QName> nestedDocument=((NestedDocument<QName>)namedProperty.getValue());
        if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.SequenceConstraint.SequenceConstraint)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceConstraints.add(parseSequenceConstraint(((NestedDocument<QName>)namedProperty.getValue())));
      }
 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.SequenceConstraint.SequenceConstraint)) {
          throw new SBOLValidationException("String_Node_Str",topLevel.getIdentity());
        }
        sequenceConstraints.add(parseSequenceConstraint(nested.get(uri)));
      }
    }
 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));
    }
  }
  ComponentDefinition c=new ComponentDefinition(topLevel.getIdentity(),type);
  if (roles != null)   c.setRoles(roles);
  if (displayId != null)   c.setDisplayId(displayId);
  if (persistentIdentity != null)   c.setPersistentIdentity(persistentIdentity);
  if (!sequences.isEmpty())   c.setSequences(sequences);
  if (!components.isEmpty())   c.setComponents(components);
  if (!sequenceAnnotations.isEmpty())   c.setSequenceAnnotations(sequenceAnnotations);
  if (!sequenceConstraints.isEmpty())   c.setSequenceConstraints(sequenceConstraints);
  if (name != null)   c.setName(name);
  if (description != null)   c.setDescription(description);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  if (version != null)   c.setVersion(version);
  c.setWasDerivedFroms(wasDerivedFroms);
  c.setWasGeneratedBys(wasGeneratedBys);
  c.setAttachments(attachments);
  ComponentDefinition oldC=SBOLDoc.getComponentDefinition(topLevel.getIdentity());
  if (oldC == null) {
    SBOLDoc.addComponentDefinition(c);
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str",c);
    }
  }
  return c;
}