class Check {

  public static String validIdentifier(String value, int maxLen, String name) {
    Check.notEmpty(value, name);
    if (value.length() > maxLen) {
      throw new IllegalArgumentException(MessageFormat
          .format("[{0}] = [{1}] exceeds max len [{2}]", name, value, maxLen));
    }
    if (!IDENTIFIER_PATTERN.matcher(value).find()) {
      throw new IllegalArgumentException(MessageFormat
          .format("[{0}] = [{1}] must be '{2}'", name, value,
              IDENTIFIER_PATTERN_STR));
    }
    return value;
  }

}