class RangeParser implements Parser<List<Range>> {

    @Override
    public List<Range> parse(final String input) throws MalformedInputException {
        List<Range> rangeList = new ArrayList<>();

        String inputNormalized = input.toLowerCase().trim();
        if (!inputNormalized.startsWith(START_WORD)) {
            throw new MalformedInputException("Header value must start with bytes=");
        }

        String[] rangesString = inputNormalized.substring(START_WORD.length()).split(RANGES_SEPARATOR);
        for (String rangeString : rangesString) {
            if (rangeString.indexOf(RANGE_SEPARATOR) == -1) {
                throw new MalformedInputException("Invalid range value " + rangeString);
            }

            String[] values = rangeString.split(RANGE_SEPARATOR);

            if (values.length != 2) {
                throw new MalformedInputException("Invalid range value " + rangeString);
            }

            rangeList.add(getRange(values));
        }

        return rangeList;
    }

}