class ParameterTool extends ExecutionConfig.GlobalJobParameters implements Serializable, Cloneable {

	public static ParameterTool fromArgs(String[] args) {
		final Map<String, String> map = new HashMap<>(args.length / 2);

		int i = 0;
		while (i < args.length) {
			final String key;

			if (args[i].startsWith("--")) {
				key = args[i].substring(2);
			} else if (args[i].startsWith("-")) {
				key = args[i].substring(1);
			} else {
				throw new IllegalArgumentException(
					String.format("Error parsing arguments '%s' on '%s'. Please prefix keys with -- or -.",
						Arrays.toString(args), args[i]));
			}

			if (key.isEmpty()) {
				throw new IllegalArgumentException(
					"The input " + Arrays.toString(args) + " contains an empty argument");
			}

			i += 1; // try to find the value

			if (i >= args.length) {
				map.put(key, NO_VALUE_KEY);
			} else if (NumberUtils.isNumber(args[i])) {
				map.put(key, args[i]);
				i += 1;
			} else if (args[i].startsWith("--") || args[i].startsWith("-")) {
				// the argument cannot be a negative number because we checked earlier
				// -> the next argument is a parameter name
				map.put(key, NO_VALUE_KEY);
			} else {
				map.put(key, args[i]);
				i += 1;
			}
		}

		return fromMap(map);
	}

	private  ParameterTool(Map<String, String> data);

}