57 lines
1.2 KiB
Java
57 lines
1.2 KiB
Java
package com.banesco.domain.model;
|
|
|
|
public class BaseResponse<T> {
|
|
|
|
private final StatusResponse status;
|
|
private final T data;
|
|
|
|
private BaseResponse(Builder<T> builder) {
|
|
this.status = builder.status;
|
|
this.data = builder.data;
|
|
}
|
|
|
|
public StatusResponse getstatus() {
|
|
return status;
|
|
}
|
|
|
|
public T getdata() {
|
|
return data;
|
|
}
|
|
|
|
public static class Builder<T> {
|
|
|
|
private StatusResponse status;
|
|
private T data;
|
|
|
|
public Builder() {
|
|
}
|
|
|
|
public Builder<T> status(StatusResponse status) {
|
|
this.status = status;
|
|
return this;
|
|
}
|
|
|
|
public Builder<T> data(T data) {
|
|
this.data = data;
|
|
return this;
|
|
}
|
|
|
|
public BaseResponse<T> build() {
|
|
// Validaciones de ser necesario
|
|
// if (attr == null || attr.isEmpty()) {
|
|
// throw new IllegalStateException("El atributo1 no puede estar vacío");
|
|
// }
|
|
return new BaseResponse<>(this);
|
|
}
|
|
}
|
|
|
|
public static <T> Builder<T> builder() {
|
|
return new Builder<>();
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "BaseResponse [status=" + status + ", data=" + data + "]";
|
|
}
|
|
}
|