package de.sstoehr.harreader.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import javax.validation.constraints.NotNull;

/**
 * Information about the response's content.
 * @see <a href="http://www.softwareishard.com/blog/har-12-spec/#content">specification</a>
 */
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class HarContent {

    private Long size;
    private Long compression;
    private String mimeType;
    private String text;
    private String encoding;
    private String comment;

    /**
     * @return Length of returned content in bytes.
     */
    @NotNull
    public Long getSize() {
        return size;
    }

    /**
     * @throws java.lang.IllegalArgumentException if size is null.
     */
    public void setSize(Long size) {
        if (size == null) {
            throw new IllegalArgumentException("Size must not be null!");
        }
        this.size = size;
    }

    /**
     * @return Number of byted saved by compression, may be null.
     */
    public Long getCompression() {
        return compression;
    }

    public void setCompression(Long compression) {
        this.compression = compression;
    }

    /**
     * @return MIME-Type of response. May include the charset.
     */
    @NotNull
    public String getMimeType() {
        return mimeType;
    }

    /**
     * @throws java.lang.IllegalArgumentException if mimeType is null.
     */
    public void setMimeType(String mimeType) {
        if (mimeType == null) {
            throw new IllegalArgumentException("MIME-Type must not be null!");
        }
        this.mimeType = mimeType;
    }

    /**
     * @return Response body loaded from server or cache, may be null.
     * Binary content may be encoded using encoding specified by {@link #getEncoding()}.
     */
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    /**
     * @return Encoding used for encoding response body, may be null.
     * @see #getText()
     */
    public String getEncoding() {
        return encoding;
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }

    /**
     * @return Comment provided by the user or application, may be null.
     */
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}

@@ -30,16 +30,62 @@
 model;%0A%0A
+import javax.validation.constraints.NotNull;%0A%0A
 import c
@@ -207,54 +207,8 @@
 e;%0A%0A
-import javax.validation.constraints.NotNull;%0A%0A
 /**%0A
@@ -1456,263 +1456,59 @@
   %7D%0A
-%0A
     
-/**%0A     * @throws java.lang.IllegalArgumentException if mimeType is null.%0A     */%0A    public void setMimeType(String mimeType) %7B%0A        if (mimeType == null) %7B%0A            throw new IllegalArgumentException(%22MIME-Type must not be null!%22);%0A        %7D
+%0A    public void setMimeType(String mimeType) %7B
 %0A   

allow empty mime type (for phantomjs)