code: public static <T extends Enum<T>> Pattern createValidationPatternFromEnumType(Class<T> enumType) {
  
          String regEx = Stream.of(enumType.getEnumConstants())
                  .map(Enum::name)
                  .collect(Collectors.joining("|", "(?i)", ""));
  
          //Enum constants may contain $ which needs to be escaped
          regEx = regEx.replace("$", "\\$");
          return Pattern.compile(regEx);
      }
docs: Create a regular expression which will match any of the values from the supplied enum type