docs: public static String nameToIdentifier(String name, IdentifierType type) {
  
          if (null == name || name.length() == 0) {
              return name;
          }
  
          // algorithm will not change an XML name that is already a legal and
          // conventional (!) Java class, method, or constant identifier
  
          boolean legalIdentifier = false;
          StringBuilder buf = new StringBuilder(name);
          boolean hasUnderscore = false;
          legalIdentifier = Character.isJavaIdentifierStart(buf.charAt(0));
  
          for (int i = 1; i < name.length() && legalIdentifier; i++) {
              legalIdentifier &= Character.isJavaIdentifierPart(buf.charAt(i));
              hasUnderscore |= '_' == buf.charAt(i);
          }
  
          boolean conventionalIdentifier = isConventionalIdentifier(buf, type);
          if (legalIdentifier && conventionalIdentifier) {
              if (JAXBUtils.isJavaKeyword(name) && type == IdentifierType.VARIABLE) {
                  name = normalizePackageNamePart(name);
              }
              if (!hasUnderscore || IdentifierType.CLASS != type) {
                  return name;
              }
          }
  
          // split into words
  
          List<String> words = new ArrayList<>();
  
          StringTokenizer st = new StringTokenizer(name, XML_NAME_PUNCTUATION_STRING);
          while (st.hasMoreTokens()) {
              words.add(st.nextToken());
          }
  
          for (int i = 0; i < words.size(); i++) {
              splitWord(words, i);
          }
  
          return makeConventionalIdentifier(words, type);
      }