All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.tmq.common.domain.result.SendResult Maven / Gradle / Ivy

package com.alibaba.tmq.common.domain.result;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.tmq.common.domain.KeyValuePair;
import com.alibaba.tmq.common.domain.Message;

/**
 * 发送结果
 * @author tianyao.myc
 *
 */
public class SendResult extends Result {

	private static final long serialVersionUID = 1471410852176915719L;
	
	/** 消息列表 */
	private List> messageKeyValueList = new ArrayList>();
	
	/** 消息全局唯一ID */
	private String messageId;
	
	public SendResult() {
		
	}
	
	public SendResult(Boolean data) {
		super(data);
	}
	
	public SendResult(ResultCode resultCode) {
		super(resultCode);
	}
	
	public SendResult(Result result) {
		super(result.getData(), result.getResultCode());
	}
	
	public SendResult(Result result, KeyValuePair messageKeyValue) {
		super(result.getData(), result.getResultCode());
		this.messageKeyValueList.add(messageKeyValue);
	}
	
	public SendResult(Result result, List> messageKeyValueList) {
		super(result.getData(), result.getResultCode());
		this.messageKeyValueList.addAll(messageKeyValueList);
	}
	
	public SendResult(Boolean data, ResultCode resultCode) {
		super(data, resultCode);
	}

	public SendResult(Boolean data, ResultCode resultCode, KeyValuePair messageKeyValue) {
		super(data, resultCode);
		this.messageKeyValueList.add(messageKeyValue);
	}

	public SendResult(Boolean data, ResultCode resultCode, List> messageKeyValueList) {
		super(data, resultCode);
		this.messageKeyValueList.addAll(messageKeyValueList);
	}
	
	public List> getMessageKeyValueList() {
		return messageKeyValueList;
	}

	public void setMessageKeyValueList(
			List> messageKeyValueList) {
		this.messageKeyValueList = messageKeyValueList;
	}

	public String getMessageId() {
		
		if(null == this.messageKeyValueList || this.messageKeyValueList.size() <= 0) {
			return messageId;
		}
		
		messageId = this.messageKeyValueList.get(0).getKey();
		
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}

	@Override
	public String toString() {
		return "SendResult [messageKeyValueList=" + messageKeyValueList
				+ ", messageId=" + messageId + ", getData()=" + getData()
				+ ", getResultCode()=" + getResultCode() + "]";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy