<commit_before>/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2007-2014 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/

package org.opennms.web.element;

import org.opennms.netmgt.model.OnmsArpInterface.StatusType;
import org.opennms.netmgt.model.OnmsVlan;
import org.opennms.netmgt.model.OnmsVlan.VlanStatus;
import org.opennms.netmgt.model.OnmsVlan.VlanType;
import org.opennms.web.api.Util;

/**
 * <p>Vlan class.</p>
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Id: $
 * @since 1.8.1
 */
public class Vlan
{
    private final int m_nodeId;
    private final int m_vlanId;
    private final String m_vlanname;
    private final String m_vlantype;
    private final String m_vlanstatus;
    private final String m_lastPollTime;
    private final String m_status;

    /* package-protected so only the NetworkElementFactory can instantiate */
    Vlan(OnmsVlan vlan)
    {
        m_nodeId = vlan.getNode().getId();
        m_vlanId = vlan.getVlanId();
        m_vlanname = vlan.getVlanName();
        m_vlantype = VlanType.getVlanTypeString(vlan.getVlanType().getIntCode());
        m_vlanstatus = VlanStatus.getVlanStatusString(vlan.getVlanStatus().getIntCode());
        m_lastPollTime = Util.formatDateToUIString(vlan.getLastPollTime()); 
        m_status = StatusType.getStatusString(vlan.getStatus().getCharCode());
    }

    /**
     * <p>toString</p>
     *
     * @return a {@link java.lang.String} object.
     */
    @Override
    public String toString()
    {
        StringBuffer str = new StringBuffer("Node Id = " + m_nodeId + "\n" );
        str.append("Vlan id = " + m_vlanId + "\n" );
        str.append("At Last Poll Time = " + m_lastPollTime + "\n" );
        str.append("Node At Status= " + m_status + "\n" );
        return str.toString();
    }


    /**
     * <p>getLastPollTime</p>
     *
     * @return a {@link java.lang.String} object.
     */
    public String getLastPollTime() {
        return m_lastPollTime;
    }

    /**
     * <p>getNodeId</p>
     *
     * @return a int.<commit_msg>Added checking for null VLAN statuses when displaying values in the web UI. Fixes bug NMS-7287.<commit_after>/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2007-2014 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/

package org.opennms.web.element;

import org.opennms.netmgt.model.OnmsArpInterface.StatusType;
import org.opennms.netmgt.model.OnmsVlan;
import org.opennms.netmgt.model.OnmsVlan.VlanStatus;
import org.opennms.netmgt.model.OnmsVlan.VlanType;
import org.opennms.web.api.Util;

/**
 * <p>Vlan class.</p>
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Id: $
 * @since 1.8.1
 */
public class Vlan
{
    private final int m_nodeId;
    private final int m_vlanId;
    private final String m_vlanname;
    private final String m_vlantype;
    private final String m_vlanstatus;
    private final String m_lastPollTime;
    private final String m_status;

    /* package-protected so only the NetworkElementFactory can instantiate */
    Vlan(OnmsVlan vlan)
    {
        m_nodeId = vlan.getNode().getId();
        m_vlanId = vlan.getVlanId();
        m_vlanname = vlan.getVlanName();
        m_vlantype = VlanType.getVlanTypeString(vlan.getVlanType() == null ? VlanType.UNKNOWN.getIntCode() : vlan.getVlanType().getIntCode());
        m_vlanstatus = VlanStatus.getVlanStatusString(vlan.getVlanStatus() == null ? VlanStatus.UNKNOWN.getIntCode() : vlan.getVlanStatus().getIntCode());
        m_lastPollTime = Util.formatDateToUIString(vlan.getLastPollTime()); 
        m_status = StatusType.getStatusString(vlan.getStatus() == null ? StatusType.UNKNOWN.getCharCode() : vlan.getStatus().getCharCode());
    }

    /**
     * <p>toString</p>
     *
     * @return a {@link java.lang.String} object.
     */
    @Override
    public String toString()
    {
        StringBuffer str = new StringBuffer("Node Id = " + m_nodeId + "\n" );
        str.append("Vlan id = " + m_vlanId + "\n" );
        str.append("At Last Poll Time = " + m_lastPollTime + "\n" );
        str.append("Node At Status= " + m_status + "\n" );
        return str.toString();
    }


    /**
     * <p>getLastPollTime</p>
     *
     * @return a {@link java.lang.String} object.
     */
    public String getLastPollTime() {
        return m_lastPollTime;
    }

    /**
     * <p>getNodeId</p>
     *
     * @return a int.
{'fraction_non_alphanumeric': 0.162534435261708, 'fraction_numerical': 0.006734006734006734, 'mean_word_length': 3.227037516170763, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1217156', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2082, 'n_words': 553}