package com.persagy.adm.diagram.core.model.virtual;

import com.google.gson.annotations.Expose;
import com.persagy.adm.diagram.core.model.EquipmentNode;

import java.util.HashMap;
import java.util.Map;

/**
 * 打包设备节点
 * @author zhaoyk
 */
public class PackNode extends EquipmentNode {

	public static final String TYPE = "packNode";

	public static final String SINGLE_PACK = "singlePack";

	/**
	 * 设备统计信息{设备类型, 设备数量}
	 */
	@Expose
	private Map<String, Integer> statInfo;

	public PackNode(){
		this.compType = TYPE;
	}

	public Map<String, Integer> getStatInfo() {
		return statInfo;
	}

	public void setStatInfo(Map<String, Integer> statInfo) {
		this.statInfo = statInfo;
	}

	public void add(String equipClassCode) {
		if(statInfo == null) {
			statInfo = new HashMap<>();
		}

		Integer i = statInfo.get(equipClassCode);
		statInfo.put(equipClassCode, i == null ? 1 : i + 1);
	}

	public int totalCount(){
		int i = 0;
		for(Integer num : statInfo.values()) {
			i += num;
		}
		return i;
	}

}
