package com.jscape.inet.http.protocol.messages;

import static com.jscape.util.Parameters.assertNotNull;
import static com.jscape.util.Parameters.assertTrue;

/**
 * @author Alex Usun
 */
public class ContentRange {
    
    public final String unit;
    public final Long start;
    public final Long end;
    public final Long size;
    
    public ContentRange(String unit, Long start, Long end, Long size) {
        assertNotNull(unit);
        this.unit = unit;
        
        assertTrue((start == null && end == null) || (start != null && end != null), "Invalid start/end values.");
        this.start = start;
        this.end = end;
        
        this.size = size;
    }
    
    @Override
    public String toString() {
        return "ContentRange {"
               + "unit='" + this.unit + '\''
               + ", start=" + this.start
               + ", end=" + this.end
               + ", size=" + this.size
               + '}';
    }
}
