class RangePartHeaderSerializer implements Serializer<RangePartHeader> {

    public long getPartHeadersLength(final List<Range> ranges,
                                     final String boundary,
                                     final String contentType,
                                     final long totalLength) {
        if (ranges.size() < 2) {
            return 0;
        }

        String partHeader = serialize(new RangePartHeader(new Range(0L, 0L), boundary, contentType, 0L));
        int partHeaderWithoutDigits = partHeader.length() - RANGE_DIGITS_LENGTH;

        long partHeadersLength = 0;

        // Initial new line
        partHeadersLength += NEW_LINE.length();

        for (Range range : ranges) {
            partHeadersLength += NEW_LINE.length()
                    + partHeaderWithoutDigits
                    + Long.toString(range.getFrom()).length()
                    + Long.toString(range.getTo()).length()
                    + Long.toString(totalLength).length();
        }

        partHeadersLength += serializeLastBoundaryDeliminator(boundary).length();

        return partHeadersLength;
    }

}