code: public static boolean validateAttachement(Attachment attachment)
        throws MonomerException, IOException, ChemistryException {
  
      String alternateId = attachment.getAlternateId();
      if (null == alternateId) {
        throw new MonomerException("Attachment must have unique ID");
      }
  
      String smiles = attachment.getCapGroupSMILES();
      if (null != smiles) {
  
        if (!Chemistry.getInstance().getManipulator().validateSMILES(smiles)) {
          throw new MonomerException(
              "Attachment cap group SMILES is invalid");
        }
  
        List<String> labels = getAttachmentLabels(smiles);
        if (null == labels || labels.size() != 1) {
          throw new MonomerException(
              "Attachment must have one R group in SMILES");
        }
  
        if (!(labels.get(0).equals(attachment.getLabel()))) {
          throw new MonomerException(
              "R group in monomer SMILES and R group label must match");
        }
      }
      return true;
    }
docs: This method validates Attachment by the following rules
  Attachment must have unique ID
  cap group SMILES must be valid
  cap group SMILES must contain one R group
  R group in SMILES must match R group label
  
  @param attachment given attachment
  @return true or false
  @throws org.helm.notation2.exception.MonomerException if attachment is not valid
  @throws java.io.IOException IO error
  @throws ChemistryException if chemistry engine can not be initialized