content: #set( $symbol_pound = '#' )
  #set( $symbol_dollar = '$' )
  #set( $symbol_escape = '\' )
  package ${package}.application.dto;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.List;
  
  public class MultiResponse<T> extends Response {
  
      private static final long serialVersionUID = 1L;
  
      private Collection<T> data;
  
      public List<T> getData() {
          if (null == data) {
              return Collections.emptyList();
          }
          if (data instanceof List) {
              return (List<T>) data;
          }
          return new ArrayList<>(data);
      }
  
      public void setData(Collection<T> data) {
          this.data = data;
      }
  
      public boolean isEmpty() {
          return data == null || data.isEmpty();
      }
  
      public boolean isNotEmpty() {
          return !isEmpty();
      }
  
      public static MultiResponse buildSuccess() {
          MultiResponse response = new MultiResponse();
          response.setSuccess(true);
          return response;
      }
  
      public static MultiResponse buildFailure(String errCode, String errMessage) {
          MultiResponse response = new MultiResponse();
          response.setSuccess(false);
          response.setErrCode(errCode);
          response.setErrMessage(errMessage);
          return response;
      }
  
      public static <T> MultiResponse<T> of(Collection<T> data) {
          MultiResponse<T> response = new MultiResponse<>();
          response.setSuccess(true);
          response.setData(data);
          return response;
      }
  
  }
  