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

com.groupbyinc.common.model.util.ControllerUtil Maven / Gradle / Ivy

package com.groupbyinc.common.model.util;

import com.groupbyinc.common.model.HttpStatus;
import com.groupbyinc.common.model.Response;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class ControllerUtil {

  public static  Response createSuccessResponse(HttpServletResponse httpStatus, T result) {
    return createResponse(httpStatus, result);
  }

  public static  Response createSuccessResponse(HttpServletResponse httpStatus, T result, List warnings) {
    return createResponse(httpStatus, result, warnings);
  }

  public static  Response createResponse(HttpServletResponse httpStatus, T result) {
    httpStatus.setStatus(200);
    return new Response<>(result);
  }

  public static  Response createResponse(HttpServletResponse httpStatus, T result, List warnings) {
    httpStatus.setStatus(200);
    return new Response<>(result, warnings);
  }

  public static  Response createResponse(HttpServletResponse response, T result, HttpStatus httpStatus) {
    response.setStatus(httpStatus.value());
    return new Response<>(result, httpStatus);
  }

  public static  Response createResponse(HttpServletResponse response, T result, HttpStatus httpStatus, List warnings) {
    response.setStatus(httpStatus.value());
    return new Response<>(result, httpStatus, warnings);
  }

  public static  Response createResponse(HttpServletResponse response, List errors, HttpStatus httpStatus) {
    response.setStatus(httpStatus.value());
    return new Response<>(errors, httpStatus);
  }

  public static  Response createResponse(HttpServletResponse response, List errors, HttpStatus httpStatus, List warnings) {
    response.setStatus(httpStatus.value());
    return new Response<>(errors, httpStatus, warnings);
  }

  public static  Response createResponse(HttpServletResponse response, HttpStatus httpStatus) {
    response.setStatus(httpStatus.value());
    return new Response<>(httpStatus);
  }

  public static  Response createResponse(HttpServletResponse response, HttpStatus httpStatus, List warnings) {
    response.setStatus(httpStatus.value());
    return new Response<>(httpStatus, warnings);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy