code: private void checkPrefix(String prefix) {
      if (prefix.length() > 0) {
        // Make sure that prefix starts with a legal character.
        if (!contains(firstChars, prefix.charAt(0))) {
          char[] chars = new char[firstChars.length];
          for (int i = 0; i < chars.length; i++) {
            chars[i] = firstChars[i].name;
          }
          throw new IllegalArgumentException(
              "prefix must start with one of: " + Arrays.toString(chars));
        }
        for (int pos = 1; pos < prefix.length(); ++pos) {
          char[] chars = new char[nonFirstChars.length];
          for (int i = 0; i < chars.length; i++) {
            chars[i] = nonFirstChars[i].name;
          }
          if (!contains(nonFirstChars, prefix.charAt(pos))) {
            throw new IllegalArgumentException(
                "prefix has invalid characters, must be one of: "
                + Arrays.toString(chars));
          }
        }
      }
    }
docs: Validates a name prefix.