package com.lanyuanxiaoyao.service.executor.task.entity;

import java.io.Serializable;

/**
 * @author lanyuanxiaoyao
 */
public class Prisoner implements Serializable {
    private final String messageId;
    private final String type;
    private final String key;
    private final String partition;
    private final Long timestamp;
    private final Boolean error;
    private final String errorMessage;

    private Prisoner(String messageId, String type, String key, String partition, Long timestamp, Boolean error, String errorMessage) {
        this.messageId = messageId;
        this.type = type;
        this.key = key;
        this.partition = partition;
        this.timestamp = timestamp;
        this.error = error;
        this.errorMessage = errorMessage;
    }

    public Prisoner(String messageId, String type, String key, String partition, Long timestamp) {
        this(messageId, type, key, partition, timestamp, false, null);
    }

    public Prisoner(String messageId, String errorMessage) {
        this(messageId, null, "error", "error", null, true, errorMessage);
    }

    public String getMessageId() {
        return messageId;
    }

    public String getType() {
        return type;
    }

    public String getKey() {
        return key;
    }

    public String getPartition() {
        return partition;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public Boolean getError() {
        return error;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    @Override
    public String toString() {
        return "Prisoner{" +
               "messageId='" + messageId + '\'' +
               ", type='" + type + '\'' +
               ", key='" + key + '\'' +
               ", partition='" + partition + '\'' +
               ", timestamp=" + timestamp +
               ", error=" + error +
               ", errorMessage='" + errorMessage + '\'' +
               '}';
    }
}
