All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.net.wanmo.common.http.jdk.pojo.ResData Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package cn.net.wanmo.common.http.jdk.pojo;

import java.io.File;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * HTTP 请求的响应数据
 */
public class ResData implements Serializable {
    public static ResData build(Map> headers) {
        return new ResData(headers);
    }

    public static ResData build(String body, Map> headers) {
        return new ResData(body, headers);
    }

    public static ResData build(File file, Map> headers) {
        return new ResData(file, headers);
    }


    // -----------------------------------------------------------
    /**
     * 如果响应的是字符串
     */
    private String body;
    /**
     * 将响应的字符串解析为对象
     */
    private Obj obj;
    /**
     * 如果响应的是文件
     */
    private File file;
    /**
     * 响应头信息
     */
    private Map> headers = new HashMap<>();

    private ResData() {
    }

    private ResData(String body) {
        this();
        this.body = body;
    }

    public ResData(File file) {
        this();
        this.file = file;
    }

    public ResData(Map> headers) {
        this();
        this.headers = headers;
    }

    public ResData(String body, Map> headers) {
        this(body);
        this.headers = headers;
    }

    public ResData(File file, Map> headers) {
        this(file);
        this.headers = headers;
    }

    public String getBody() {
        return body;
    }

    public ResData setBody(String body) {
        this.body = body;
        return this;
    }

    public Obj getObj() {
        return obj;
    }

    public ResData setObj(Obj obj) {
        this.obj = obj;
        return this;
    }

    public File getFile() {
        return file;
    }

    public ResData setFile(File file) {
        this.file = file;
        return this;
    }

    public Map> getHeaders() {
        return headers;
    }

    public ResData setHeaders(Map> headers) {
        this.headers = headers;
        return this;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy