com.kuangkie.carbon.common.IntegrationMsg Maven / Gradle / Ivy
package com.kuangkie.carbon.common;
import java.util.ArrayList;
import java.util.Collection;
import com.kuangkie.carbon.enun.MessageState;
public class IntegrationMsg {
private String code;
private MessageState state;
public IntegrationMsg(MessageState state, String code) {
this.state = state;
this.code = code;
}
private Collection debug, info, warn, refuse, error;
public String getRecordCode() {
return code;
}
public void setRecordCode(String code) {
this.code = code;
}
public MessageState getState() {
return state;
}
public void setState(MessageState state) {
this.state = state;
}
public Collection getInfo() {
return info;
}
public void setInfo(Collection info) {
this.info = info;
}
public Collection getWarn() {
return warn;
}
public void setWarn(Collection warn) {
this.warn = warn;
}
public Collection getRefuse() {
return refuse;
}
public void setRefuse(Collection refuse) {
this.refuse = refuse;
}
public Collection getDebug() {
return debug;
}
public void setDebug(Collection debug) {
this.debug = debug;
}
public Collection getError() {
return error;
}
public void setError(Collection syserror) {
this.error = syserror;
}
public boolean success() {
return MessageState.SUCCESS == getState();
}
public String getWarnMsgContentStr() {
Collection allMsgs = new ArrayList<>();
Collection msgs = this.getError();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getRefuse();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getWarn();
if (msgs != null) {
allMsgs.addAll(msgs);
}
if (allMsgs.isEmpty()) {
return null;
} else {
return toContentString(allMsgs);
}
}
public String getWarnMsgStr() {
Collection allMsgs = new ArrayList<>();
Collection msgs = this.getError();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getRefuse();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getWarn();
if (msgs != null) {
allMsgs.addAll(msgs);
}
if (allMsgs.isEmpty()) {
return null;
} else {
return toString(allMsgs);
}
}
public String getRefuseMsgContentStr() {
Collection allMsgs = new ArrayList<>();
Collection msgs = this.getError();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getRefuse();
if (msgs != null) {
allMsgs.addAll(msgs);
}
if (allMsgs.isEmpty()) {
return null;
} else {
return toContentString(allMsgs);
}
}
public String getRefuseMsgStr() {
Collection allMsgs = new ArrayList<>();
Collection msgs = this.getError();
if (msgs != null) {
allMsgs.addAll(msgs);
}
msgs = this.getRefuse();
if (msgs != null) {
allMsgs.addAll(msgs);
}
if (allMsgs.isEmpty()) {
return null;
} else {
return toString(allMsgs);
}
}
private String toString(Collection msgs) {
if (msgs != null && !msgs.isEmpty()) {
StringBuilder sb = new StringBuilder();
msgs.forEach(m -> {
sb.append(m.toString());
sb.append("; ");
});
return sb.toString();
} else {
return "";
}
}
private String toContentString(Collection msgs) {
if (msgs != null && !msgs.isEmpty()) {
StringBuilder sb = new StringBuilder(" ");
msgs.forEach(m -> {
sb.append(m.getContent());
sb.append("; ");
});
return sb.toString();
} else {
return "";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy