code: static String[] generateAliases(String base) {
          int length = base.length();
          if (length <= 1) {
              return new String[]{base.toUpperCase(), base.toLowerCase()};
          }
  
          ArrayList<String> aliases = new ArrayList<String>(4);
  
          StringBuilder buf = new StringBuilder();
  
          int i;
          for (i=0; i<length; ) {
              char c = base.charAt(i++);
              if (c == '_' || !Character.isJavaIdentifierPart(c)) {
                  // Keep scanning for first letter.
                  buf.append(c);
              } else {
                  buf.append(Character.toUpperCase(c));
                  break;
              }
          }
  
          boolean canSeparate = false;
          boolean appendedIdentifierPart = false;
  
          for (; i<length; i++) {
              char c = base.charAt(i);
              if (c == '_' || !Character.isJavaIdentifierPart(c)) {
                  canSeparate = false;
                  appendedIdentifierPart = false;
              } else if (Character.isLowerCase(c)) {
                  canSeparate = true;
                  appendedIdentifierPart = true;
              } else {
                  if (appendedIdentifierPart &&
                      i + 1 < length && Character.isLowerCase(base.charAt(i + 1))) {
                      canSeparate = true;
                  }
                  if (canSeparate) {
                      buf.append('_');
                  }
                  canSeparate = false;
                  appendedIdentifierPart = true;
              }
              buf.append(c);
          }
  
          String derived = buf.toString();
  
          addToSet(aliases, derived.toUpperCase());
          addToSet(aliases, derived.toLowerCase());
          addToSet(aliases, derived);
          addToSet(aliases, base.toUpperCase());
          addToSet(aliases, base.toLowerCase());
          addToSet(aliases, base);
  
          return aliases.toArray(new String[aliases.size()]);
      }
docs: Generates aliases for the given name, converting camel case form into
  various underscore forms.