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

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

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

import cn.net.wanmo.common.util.CollectionUtil;
import cn.net.wanmo.common.util.MapUtil;

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

public class ResData implements Serializable {
    private String body;
    private Map> headers;

    private ResData() {
    }

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

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

    public String getBody() {
        return body;
    }

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

    public Map> getHeaders() {
        return headers;
    }

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

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



    public String getHeaderField(String key) {
        if (MapUtil.isEmpty(headers)) {
            return null;
        }

        List list = headers.get(key);
        if (CollectionUtil.isEmpty(list)) {
            return null;
        }

        return list.get(0);
    }

    @Override
    public String toString() {
        return "ResData{" +
                "body='" + body + '\'' +
                ", headers=" + headers +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy