/**
 * <p>Copyright:Copyright(c) 2017</p>
 * <p>Company:上海中信信息发展股份有限公司</p>
 * <p>包名:com.cesgroup.cesmonitor.service.map</p>
 * <p>文件名:Device.java</p>
 * <p>创建时间:2017年9月4日 下午2:38:25</p>
 * <p>作者:zhang.erwei</p>
 */

package com.cesgroup.cesmonitor.service.map;

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

/**
 *
 * @author zhang.erwei
 * @version 1.0.0 2017年9月4日
 */
public class Device {

    private String ip;

    private Integer snmpPort = 161;

    private String community = "aaa";

    private Integer hostid;

    private Map<String, Device> link = new HashMap<String, Device>();

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getSnmpPort() {
        return snmpPort;
    }

    public void setSnmpPort(Integer snmpPort) {
        this.snmpPort = snmpPort;
    }

    public String getCommunity() {
        return community;
    }

    public void setCommunity(String community) {
        this.community = community;
    }

    public Map<String, Device> getLink() {
        return link;
    }

    public Integer getHostid() {
        return hostid;
    }

    public void setHostid(Integer hostid) {
        this.hostid = hostid;
    }

    public boolean containIP(String ip, Integer hostId) {
        if (this.ip == null) {
            return false;
        }
        if (this.ip.equals(ip)) {
            this.hostid = hostId;
            return true;
        }
        for (Device d : link.values()) {
            if (d.containIP(ip, hostId)) {
                return true;
            }
        }
        return false;
    }

}
