com.github.dts.sdk.util.DmlDTO Maven / Gradle / Ivy
package com.github.dts.sdk.util;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
public class DmlDTO {
private static final Object[] EMPTY = new Object[0];
private String tableName;
private String database;
private List pkNames;
private Long es;
private Long ts;
private String type;
private Map old;
private Map data;
private List indexNames;
private List desc;
private Boolean effect;
private transient Object[] id;
public Boolean getEffect() {
return effect;
}
public void setEffect(Boolean effect) {
this.effect = effect;
}
public String getIdString() {
Object id = getId();
return id == null ? null : id.toString();
}
public Long getIdLong() {
Object id = getId();
return id == null ? null : Long.valueOf(id.toString());
}
public Integer getIdInteger() {
Object id = getId();
return id == null ? null : Integer.valueOf(id.toString());
}
public Object getId() {
Object[] ids = getIds();
return ids.length > 0 ? ids[0] : null;
}
public Object[] getIds() {
if (id == null) {
Object[] ids;
if (pkNames == null || pkNames.isEmpty()) {
ids = EMPTY;
} else {
ids = new Object[pkNames.size()];
for (int i = 0; i < pkNames.size(); i++) {
String pkName = pkNames.get(i);
Object rowId = null;
if (old != null && old.containsKey(pkName)) {
rowId = old.get(pkName);
} else if (data != null && data.containsKey(pkName)) {
rowId = data.get(pkName);
}
ids[i] = rowId;
}
}
id = ids;
}
return id;
}
@Override
public String toString() {
return "DmlDTO{" +
"tableName='" + tableName + '\'' +
", database='" + database + '\'' +
", es=" + new Timestamp(es) +
", type='" + type + '\'' +
", indexNames=" + indexNames +
", desc=" + desc +
'}';
}
public List getDesc() {
return desc;
}
public void setDesc(List desc) {
this.desc = desc;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getDatabase() {
return database;
}
public void setDatabase(String database) {
this.database = database;
}
public List getPkNames() {
return pkNames;
}
public void setPkNames(List pkNames) {
this.pkNames = pkNames;
}
public Long getEs() {
return es;
}
public void setEs(Long es) {
this.es = es;
}
public Long getTs() {
return ts;
}
public void setTs(Long ts) {
this.ts = ts;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map getOld() {
return old;
}
public void setOld(Map old) {
this.old = old;
}
public Map getData() {
return data;
}
public void setData(Map data) {
this.data = data;
}
public List getIndexNames() {
return indexNames;
}
public void setIndexNames(List indexNames) {
this.indexNames = indexNames;
}
}