package com.eactive.eai.common.messagekey;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

// 어댑터에서 사용되는 메시지의 Key 추출 정보 
public class MessageKeyVO implements Serializable {
	private static final long serialVersionUID = 1L;
	private String name; // 어댑터업무그룹명[TSEAIFR04.AdptrBzwkGroupName]
	private String msgTp; // 메시지구분코드[TSEAIFR04.MsgDstcd]
	private String exrTp; // 입출력구분코드[TSEAIFR04.IODstcd]

	private int currentGroupKey; // 메모리정보

	private List<MessageKeyGroupVO> alMsgGroups = new ArrayList<>();

	public List<MessageKeyGroupVO> getAlMsgGroups() {
		return alMsgGroups;
	}

	public void setAlMsgGroups(List<MessageKeyGroupVO> alMsgGroups) {
		this.alMsgGroups = alMsgGroups;
	}

	public void setMessageKeyGroup(int key, MessageKeyGroupVO vo) {
		this.alMsgGroups.set(key, vo);
	}

	public MessageKeyGroupVO getMessageKeyGroup(int key) {
		return alMsgGroups.get(key);
	}

	public void addMessageKeyGroup(MessageKeyGroupVO vo) {
		this.alMsgGroups.add(vo);
	}

	public int getCurrentGroupKey() {
		return currentGroupKey;
	}

	public void setCurrentGroupKey(int currentGroupKey) {
		this.currentGroupKey = currentGroupKey;
	}

	public MessageKeyVO() {
		this("");
	}

	public MessageKeyVO(String name) {
		this(name, "", "");
	}

	public MessageKeyVO(String name, String msgTp, String exrTp) {
		this.name = name;
		this.msgTp = msgTp;
		this.exrTp = exrTp;
		this.alMsgGroups = new ArrayList<MessageKeyGroupVO>();
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return this.name;
	}

	public void setMsgTp(String msgTp) {
		this.msgTp = msgTp;
	}

	public String getMsgTp() {
		return this.msgTp;
	}

	public void setExrTp(String exrTp) {
		this.exrTp = exrTp;
	}

	public String getExrTp() {
		return this.exrTp;
	}

	@Override
	public String toString() {
		return "MessageKeyVO [name=" + name + ", msgTp=" + msgTp + ", exrTp=" + exrTp + ", currentGroupKey="
				+ currentGroupKey + ", \n alMsgGroups=" + printMessageGroups() + "\n]";
	}

	private String printMessageGroups() {
		StringBuilder sb = new StringBuilder();
		alMsgGroups.forEach(group -> sb.append(group.toString()).append("\n  | "));
		return sb.toString();
	}
}
