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

top.cutexingluo.tools.bridge.servlet.adapter.HttpServletResponseDataAdapter Maven / Gradle / Ivy

The newest version!
package top.cutexingluo.tools.bridge.servlet.adapter;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.cutexingluo.tools.bridge.servlet.HttpServletResponseData;
import top.cutexingluo.tools.common.base.IData;
import top.cutexingluo.tools.common.base.IResult;
import top.cutexingluo.tools.utils.ee.web.front.XTResponseUtil;

import java.io.IOException;

/**
 * HttpServletResponseData 适配器
 *
 * @author XingTian
 * @version 1.0.0
 * @date 2024/8/12 11:40
 */
@Data
@AllArgsConstructor
public class HttpServletResponseDataAdapter implements HttpServletResponseAdapter, IData {

    protected HttpServletResponseData data;

    @Contract("_ -> new")
    public static @NotNull HttpServletResponseDataAdapter of(HttpServletResponseData data) {
        return new HttpServletResponseDataAdapter(data);
    }

    @Override
    public HttpServletResponseData data() {
        return data;
    }

    @Override
    public void response(String content, int rspStatusCode) throws IOException {
        XTResponseUtil.response(data.getResponse(), content, rspStatusCode);
    }

    @Override
    public  void response(IResult result, int rspStatusCode) throws IOException {
        XTResponseUtil.response(data.getResponse(), result, rspStatusCode);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy