code: public void addMonomer(Monomer monomer, boolean dbChanged)
        throws IOException, MonomerException {
      Map<String, Monomer> monomerMap = monomerDB.get(monomer.getPolymerType());
      String polymerType = monomer.getPolymerType();
      String alternateId = monomer.getAlternateId();
      String smilesString = monomer.getCanSMILES();
  
      try {
        smilesString = SMILES.getUniqueExtendedSMILES(smilesString);
      } catch (Exception e) {
        smilesString = monomer.getCanSMILES();
      }
  
      boolean hasSmilesString = (smilesString != null && smilesString.length() > 0);
  
      if (null == monomerMap) {
        monomerMap = new TreeMap<String, Monomer>(String.CASE_INSENSITIVE_ORDER);
        monomerDB.put(polymerType, monomerMap);
      }
  
      Monomer copyMonomer = DeepCopy.copy(monomer);
  
      // ensure the canonical SMILES is indexed in the monomer store
      if (hasSmilesString) {
        copyMonomer.setCanSMILES(smilesString);
      }
  
      boolean alreadyAdded = false;
      alreadyAdded = monomerMap.containsKey(alternateId);
  
      if (!alreadyAdded) {
        monomerMap.put(alternateId, copyMonomer);
  
        boolean alreadyInSMILESMap = hasSmilesString
            && (smilesMonomerDB.containsKey(smilesString));
  
        if (!alreadyInSMILESMap) {
          smilesMonomerDB.put(smilesString, copyMonomer);
        }
      }
  
      if (dbChanged) {
        MonomerFactory.setDBChanged(true);
      }
    }
docs: Adds a monomer to the store and optionally sets the dbChanged flag
  
  @param monomer given monomer
  @param dbChanged if db was changed
  @throws IOException if the monomer store can not be saved
  @throws MonomerException if the monomer is not valid