public static <T extends Number> T getNumericalHeader(Map<String, ?> args, String header, boolean required,
      Function<String, T> converter) throws RestServiceException {
    // if getHeader() is no longer called, tests for this function have to be changed.
    String value = getHeader(args, header, required);
    if (value != null) {
      try {
        return converter.apply(value);
      } catch (NumberFormatException e) {
        throw new RestServiceException("Invalid value for " + header + ": " + value, e,
            RestServiceErrorCode.InvalidArgs);
      }
    }
    return null;
  }
Gets the value of a header as a {@link Number}, using the provided converter function to parse the string.
@param args a map of arguments to be used to look for {@code header}.
@param header the name of the header.
@param required if {@code true}, {@link RestServiceException} will be thrown if {@code header} is not present
                in {@code args}.
@param converter a function to convert from a {@link String} to the desired numerical type. This should throw
                 {@link NumberFormatException} if the argument is not a valid number.
@return the value of {@code header} in {@code args} if it exists. If it does not exist and {@code required} is
         {@code false}, then returns null.
@throws RestServiceException same as cases of {@link #getHeader(Map, String, boolean)} and if the value cannot be
                             converted to a {@link Long}.
ambry-api/src/main/java/com/github/ambry/rest/RestUtils.java