code: static String normalizeHostnamePattern(String hostnamePattern) {
          requireNonNull(hostnamePattern, "hostnamePattern");
          if (needsNormalization(hostnamePattern)) {
              hostnamePattern = IDN.toASCII(hostnamePattern, IDN.ALLOW_UNASSIGNED);
          }
  
          if (!"*".equals(hostnamePattern) &&
              !HOSTNAME_PATTERN.matcher(hostnamePattern.startsWith("*.") ? hostnamePattern.substring(2)
                                                                         : hostnamePattern).matches()) {
              throw new IllegalArgumentException("hostnamePattern: " + hostnamePattern);
          }
  
          return Ascii.toLowerCase(hostnamePattern);
      }
docs: IDNA ASCII conversion, case normalization and validation.