50 lines
1.4 KiB
Java
50 lines
1.4 KiB
Java
package com.myoa.engineering.crawl.ppomppu.support.dto;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import lombok.Getter;
|
|
|
|
/**
|
|
* ResponseError
|
|
*
|
|
* @author Shin Woo-jin (woozu.shin@kakaoent.com)
|
|
* @since 2021-09-07
|
|
*/
|
|
@Getter
|
|
public class APIResponseError<K, V> implements Serializable {
|
|
|
|
private static final long serialVersionUID = 931593091836887301L;
|
|
|
|
private String code;
|
|
private String message;
|
|
private Map<K, V> reasons;
|
|
|
|
public APIResponseError() {}
|
|
|
|
public APIResponseError(String code, String message, Map<K, V> reasons) {
|
|
this.code = code;
|
|
this.message = message;
|
|
this.reasons = reasons;
|
|
}
|
|
|
|
public static <K, V> APIResponseError<K, V> of(String code, String message, Map<K, V> reasons) {
|
|
return new APIResponseError<>(code, message, reasons);
|
|
}
|
|
|
|
public static APIResponseError<String, String> of(
|
|
String code, String message, String reasonKey, String reasonValue) {
|
|
final Map<String, String> reasons = new HashMap<>();
|
|
reasons.put(reasonKey, reasonValue);
|
|
return new APIResponseError<String, String>(code, message, reasons);
|
|
}
|
|
|
|
public static APIResponseError<Void, Void> of(String code, String message) {
|
|
return new APIResponseError<>(code, message, null);
|
|
}
|
|
|
|
public static APIResponseError<Void, Void> of(String code) {
|
|
return new APIResponseError<>(code, null, null);
|
|
}
|
|
}
|