docs: @Override
      public String generateExpression(int flagsAdd)
      {
          int flags = m_flags | flagsAdd;
          StringBuilder sb = new StringBuilder();
          if (m_leader != null) {
              sb.append(m_leader);
          }
          // Need a non-capturing group when either an explicit non-capturing group is
          // requested or it is optional. The only case where a non-capturing group isn't
          // needed for an optional is an explicit capture without leading space.
          boolean captureGroup = (flags & SQLPatternFactory.CAPTURE) != 0;
          boolean explicitNonCaptureGroup = !captureGroup && (flags & SQLPatternFactory.GROUP) != 0;
          boolean optional = ((flags & SQLPatternFactory.OPTIONAL) != 0);
          // Suppress the leading space at this level when it should be pushed down to the child.
          boolean leadingSpace = ((flags & SQLPatternFactory.LEADING_SPACE) != 0);
          boolean leadingSpaceToChild = ((flags & SQLPatternFactory.ADD_LEADING_SPACE_TO_CHILD) != 0);
          boolean childLeadingSpace = ((flags & SQLPatternFactory.CHILD_SPACE_SEPARATOR) != 0 ||
                                       (leadingSpace && leadingSpaceToChild));
          boolean nonCaptureGroup = (explicitNonCaptureGroup ||
                                    (optional && (!captureGroup || leadingSpace)));
          boolean innerOptional = optional && captureGroup && !nonCaptureGroup;
          boolean outerOptional = optional && nonCaptureGroup;
          if (nonCaptureGroup) {
              sb.append("(?:");
          }
          if (leadingSpace && !leadingSpaceToChild) {
              // Protect something like an OR sequence by using an inner group
              sb.append("\\s+(?:");
          }
          if (captureGroup) {
              if (m_captureLabel != null) {
                  sb.append(String.format("(?<%s>", m_captureLabel));
              }
              else {
                  sb.append("(");
              }
          }
          for (int i = 0; i < m_parts.length; ++i) {
              int flagsAddChild = 0;
              if (i > 0) {
                  if (m_separator != null) {
                      sb.append(m_separator);
                  }
                  if (childLeadingSpace) {
                      flagsAddChild |= SQLPatternFactory.LEADING_SPACE;
                  }
              }
              else if (childLeadingSpace && leadingSpaceToChild) {
                  flagsAddChild |= SQLPatternFactory.LEADING_SPACE;
              }
              sb.append(m_parts[i].generateExpression(flagsAddChild));
          }
          if (captureGroup) {
              sb.append(")");
          }
          if (innerOptional) {
              sb.append("?");
          }
          if (leadingSpace && !leadingSpaceToChild) {
              sb.append(")");
          }
          if (nonCaptureGroup) {
              sb.append(")");
          }
          if (outerOptional) {
              sb.append("?");
          }
          if (m_trailer != null) {
              sb.append(m_trailer);
          }
          return sb.toString();
      }