package com.lanyuanxiaoyao.service.common.entity;

import java.io.Serializable;
import java.util.Map;

/**
 * 从 Pulsar 读取的消息封装
 *
 * @author lanyuanxiaoyao
 * @version 0.0.1
 * @date 2021-11-25
 */
public class Record implements Serializable {
    private Source source;
    private Statement statement;

    public Record() {
    }

    public Source getSource() {
        return source;
    }

    public void setSource(Source source) {
        this.source = source;
    }

    public Statement getStatement() {
        return statement;
    }

    public void setStatement(Statement statement) {
        this.statement = statement;
    }

    @Override
    public String toString() {
        return "Record{" +
                "source=" + source +
                ", statement=" + statement +
                '}';
    }

    public static class Source implements Serializable {
        private String sourceId;
        private String sourceType;
        private String sourcePos;
        private String currentTs;

        public Source() {
        }

        public String getSourceId() {
            return sourceId;
        }

        public void setSourceId(String sourceId) {
            this.sourceId = sourceId;
        }

        public String getSourceType() {
            return sourceType;
        }

        public void setSourceType(String sourceType) {
            this.sourceType = sourceType;
        }

        public String getSourcePos() {
            return sourcePos;
        }

        public void setSourcePos(String sourcePos) {
            this.sourcePos = sourcePos;
        }

        public String getCurrentTs() {
            return currentTs;
        }

        public void setCurrentTs(String currentTs) {
            this.currentTs = currentTs;
        }

        @Override
        public String toString() {
            return "Source{" +
                    "sourceId='" + sourceId + '\'' +
                    ", sourceType='" + sourceType + '\'' +
                    ", sourcePos='" + sourcePos + '\'' +
                    ", currentTs='" + currentTs + '\'' +
                    '}';
        }
    }

    public static class Statement implements Serializable {
        private String schema;
        private String table;
        private String opStatement;
        private String opType;
        private String op;
        private String opTs;
        private String version;
        private Map<String, Object> before;
        private Map<String, Object> after;

        public Statement() {
        }

        public String getSchema() {
            return schema;
        }

        public void setSchema(String schema) {
            this.schema = schema;
        }

        public String getTable() {
            return table;
        }

        public void setTable(String table) {
            this.table = table;
        }

        public String getOpStatement() {
            return opStatement;
        }

        public void setOpStatement(String opStatement) {
            this.opStatement = opStatement;
        }

        public String getOpType() {
            return opType;
        }

        public void setOpType(String opType) {
            this.opType = opType;
        }

        public String getOp() {
            return op;
        }

        public void setOp(String op) {
            this.op = op;
        }

        public String getOpTs() {
            return opTs;
        }

        public void setOpTs(String opTs) {
            this.opTs = opTs;
        }

        public String getVersion() {
            return version;
        }

        public void setVersion(String version) {
            this.version = version;
        }

        public Map<String, Object> getBefore() {
            return before;
        }

        public void setBefore(Map<String, Object> before) {
            this.before = before;
        }

        public Map<String, Object> getAfter() {
            return after;
        }

        public void setAfter(Map<String, Object> after) {
            this.after = after;
        }

        @Override
        public String toString() {
            return "Statement{" +
                    "schema='" + schema + '\'' +
                    ", table='" + table + '\'' +
                    ", opStatement='" + opStatement + '\'' +
                    ", opType='" + opType + '\'' +
                    ", op='" + op + '\'' +
                    ", opTs='" + opTs + '\'' +
                    ", version='" + version + '\'' +
                    ", before=" + before +
                    ", after=" + after +
                    '}';
        }
    }
}
