/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2009-2011 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2011 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.3-b01-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2009.01.29 at 01:15:48 PM EST
//
package org.opennms.netmgt.provision.persist.requisition;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
/**
* <p>RequisitionMonitoredService class.</p>
*
* @author ranger
* @version $Id: $
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="", propOrder = { "m_categories" })
@XmlRootElement(name="monitored-service")
public class RequisitionMonitoredService implements Comparable<RequisitionMonitoredService> {
@XmlElement(name="category")
protected List<RequisitionCategory> m_categories = new ArrayList<RequisitionCategory>();;
@XmlAttribute(name="service-name", required=true)
protected String m_serviceName;
/**
* <p>Constructor for RequisitionMonitoredService.</p>
*/
public RequisitionMonitoredService() {
}
/**
* <p>Constructor for RequisitionMonitoredService.</p>
*
* @param serviceName a {@link java.lang.String} object.
*/
public RequisitionMonitoredService(String serviceName) {
m_serviceName = serviceName;
}
/**
* <p>getCategoryCount</p>
*
* @return a int.
*/
@XmlTransient
public int getCategoryCount() {
return (m_categories == null) ? 0 : m_categories.size();
}
/* backwards compatibility with ModelImport */
/**
* <p>getCategory</p>
*
* @return an array of {@link org.opennms.netmgt.provision.persist.requisition.RequisitionCategory} objects.
*/
@XmlTransient
public RequisitionCategory[] getCategory() {
return m_categories.toArray(new RequisitionCategory[] {});
}
/**
* <p>getCategories</p>
*
* @return a {@link java.util.List} object.
*/
public List<RequisitionCategory> getCategories() {
if (m_categories == null) {
m_categories = new ArrayList<RequisitionCategory>();
}
return m_categories;
}
/**
* <p>setCategories</p>
*
* @param categories a {@link java.util.List} object.
*/
public void setCategories(List<RequisitionCategory> categories) {
m_categories = categories;
}
/**
* <p>deleteCategory</p>
*
* @param category a {@link org.opennms.netmgt.provision.persist.requisition.RequisitionCategory} object.
*/
public void deleteCategory(RequisitionCategory category) {
if (m_categories != null) {
Iterator<RequisitionCategory> i = m_categories.iterator();
while (i.hasNext()) {
RequisitionCategory cat = i.next();
if (cat.getName().equals(category.getName())) {
i.remove();
break;
}
}
}
}
/**
* <p>deleteCategory</p>
*
* @param category a {@link java.lang.String} object.
*/
public void deleteCategory(String category) {
if (m_categories != null) {
Iterator<RequisitionCategory> i = m_categories.iterator();
while (i.hasNext()) {
RequisitionCategory cat = i.next();
if (cat.getName().equals(category)) {
i.remove();
break;
}
}
}
}
/**
* <p>insertCategory</p>
*
* @param category a {@link org.opennms.netmgt.provision.persist.requisition.RequisitionCategory} object.
*/
public void insertCategory(RequisitionCategory category) {
Iterator<RequisitionCategory> iterator = m_categories.iterator();
while (iterator.hasNext()) {
RequisitionCategory existing = iterator.next();
if (existing.getName().equals(category.getName())) {
iterator.remove();
}
}
m_categories.add(0, category);
}
/**
* <p>getServiceName</p>
*
* @return a {@link java.lang.String} object.
*/
public String getServiceName() {
return m_serviceName;
}
/**
* <p>setServiceName</p>
*
* @param value a {@link java.lang.String} object.
*/
public void setServiceName(String value) {
m_serviceName = value;
}
@Override
public boolean equals(Object o) {
if (o instanceof RequisitionMonitoredService) {
return this.compareTo((RequisitionMonitoredService)o) == 0;
} else return false;
}
public int compareTo(RequisitionMonitoredService o) {
return this.m_serviceName.compareTo(o.getServiceName());
}
}