com.groupbyinc.common.model.Status Maven / Gradle / Ivy
package com.groupbyinc.common.model;
import java.time.Clock;
public class Status {
public static final int SUBCODE_DEFAULT = 0;
private static Clock systemClock = Clock.systemUTC();
private Integer code;
private Integer internalCode;
private String message;
private AdditionalInfo additionalInfo;
private Long serverTimestamp;
public Status(HttpStatus httpStatus) {
this.code = httpStatus.value();
this.internalCode = SUBCODE_DEFAULT;
this.message = httpStatus.getReasonPhrase();
this.additionalInfo = null;
this.serverTimestamp = systemClock.millis();
}
public Status() {
this.code = HttpStatus.OK.value();
this.internalCode = SUBCODE_DEFAULT;
this.message = HttpStatus.OK.getReasonPhrase();
this.additionalInfo = null;
this.serverTimestamp = systemClock.millis();
}
public static void setSystemClock(Clock systemClock) {
Status.systemClock = systemClock;
}
public Integer getCode() {
return code;
}
public Status setCode(Integer code) {
this.code = code;
return this;
}
public Integer getInternalCode() {
return internalCode;
}
public Status setInternalCode(Integer internalCode) {
this.internalCode = internalCode;
return this;
}
public String getMessage() {
return message;
}
public Status setMessage(String message) {
this.message = message;
return this;
}
public AdditionalInfo getAdditionalInfo() {
return additionalInfo;
}
public Status setAdditionalInfo(AdditionalInfo additionalInfo) {
this.additionalInfo = additionalInfo;
return this;
}
public Long getServerTimestamp() {
return serverTimestamp;
}
public Status setServerTimestamp(Long serverTimestamp) {
this.serverTimestamp = serverTimestamp;
return this;
}
}