DateFormats + now(), today()
parent
709589106f
commit
a24cde0327
@ -0,0 +1,114 @@
|
||||
package cokr.xit.foundation.data;
|
||||
|
||||
import cokr.xit.foundation.Assert;
|
||||
|
||||
public class DataProc {
|
||||
public static enum Type {
|
||||
/** 데이터 생성 */
|
||||
CREATE("C"),
|
||||
/** 데이터 수정 */
|
||||
UPDATE("U"),
|
||||
/** 데이터 삭제 */
|
||||
DELETE("D");
|
||||
|
||||
private final String code;
|
||||
|
||||
private Type(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**데이터 작업 유형의 코드를 반환한다.
|
||||
* @return 데이터 작업 유형 코드
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**코드에 해당하는 Type을 반환한다.
|
||||
* @param code 데이터 작업 유형 코드
|
||||
* @return DataProc
|
||||
*/
|
||||
public static Type codeOf(String code) {
|
||||
if (Assert.isEmpty(code))
|
||||
return null;
|
||||
|
||||
for (Type type: values()) {
|
||||
if (type.code.equals(code))
|
||||
return type;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("code: " + code);
|
||||
}
|
||||
}
|
||||
|
||||
private Type type;
|
||||
private Object target;
|
||||
private Boolean success;
|
||||
private String message;
|
||||
private DataObject info;
|
||||
private Throwable error;
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public DataProc setType(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getTarget() {
|
||||
return (T)target;
|
||||
}
|
||||
|
||||
public DataProc setTarget(Object target) {
|
||||
this.target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return error == null
|
||||
&& Boolean.TRUE.equals(Assert.ifEmpty(success, Boolean.TRUE));
|
||||
}
|
||||
|
||||
public DataProc setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public DataProc setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataObject getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getInfo(String key) {
|
||||
if (info == null) return null;
|
||||
return (T)info.get(key);
|
||||
}
|
||||
|
||||
public DataProc setInfo(String key, Object obj) {
|
||||
if (info == null)
|
||||
info = new DataObject();
|
||||
info.put(key, obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public DataProc setError(Throwable error) {
|
||||
this.error = Assert.rootCause(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
package cokr.xit.foundation.data;
|
||||
|
||||
import cokr.xit.foundation.Assert;
|
||||
|
||||
/**데이터 작업 유형
|
||||
* @author mjkhan
|
||||
*/
|
||||
public enum ProcType {
|
||||
/** 데이터 생성 */
|
||||
CREATE("C"),
|
||||
/** 데이터 수정 */
|
||||
UPDATE("U"),
|
||||
/** 데이터 삭제 */
|
||||
DELETE("D");
|
||||
|
||||
private final String code;
|
||||
|
||||
private ProcType(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**데이터 작업 유형의 코드를 반환한다.
|
||||
* @return 데이터 작업 유형 코드
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**코드에 해당하는 ProcType을 반환한다.
|
||||
* @param code 데이터 작업 유형 코드
|
||||
* @return ProcType
|
||||
*/
|
||||
public static ProcType codeOf(String code) {
|
||||
if (Assert.isEmpty(code))
|
||||
return null;
|
||||
|
||||
for (ProcType procType: values()) {
|
||||
if (procType.code.equals(code))
|
||||
return procType;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("code: " + code);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue