2020-09-15 03:16:26 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
|
|
|
*
|
|
|
|
* This file is part of StatoolInfos, simple service statistics tool.
|
|
|
|
*
|
|
|
|
* StatoolInfos 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.
|
|
|
|
*
|
|
|
|
* StatoolInfos 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 StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package fr.devinsy.statoolinfos.core;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2020-09-25 04:36:38 +02:00
|
|
|
import java.util.Collections;
|
2020-09-15 03:16:26 +02:00
|
|
|
|
2020-09-25 15:46:30 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2020-09-15 03:16:26 +02:00
|
|
|
/**
|
|
|
|
* The Class Services.
|
|
|
|
*/
|
|
|
|
public class Services extends ArrayList<Service>
|
|
|
|
{
|
|
|
|
private static final long serialVersionUID = -6288956439933064467L;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new services.
|
|
|
|
*/
|
|
|
|
public Services()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
2020-09-25 04:36:38 +02:00
|
|
|
|
2020-09-25 05:44:40 +02:00
|
|
|
/**
|
|
|
|
* Gets the by.
|
|
|
|
*
|
|
|
|
* @param category
|
|
|
|
* the category
|
|
|
|
* @return the by
|
|
|
|
*/
|
|
|
|
public Services getBy(final Category category)
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
result = new Services();
|
|
|
|
|
|
|
|
for (Service service : this)
|
|
|
|
{
|
|
|
|
if (category.matches(service))
|
|
|
|
{
|
|
|
|
result.add(service);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-25 15:46:30 +02:00
|
|
|
/**
|
|
|
|
* Gets the by.
|
|
|
|
*
|
|
|
|
* @param software
|
|
|
|
* the software
|
|
|
|
* @return the by
|
|
|
|
*/
|
|
|
|
public Services getBy(final Software software)
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
result = new Services();
|
|
|
|
|
|
|
|
for (Service service : this)
|
|
|
|
{
|
|
|
|
String serviceSoftwareName = StatoolInfosUtils.toTechnicalName(service.getSoftwareName());
|
|
|
|
String softwareName = StatoolInfosUtils.toTechnicalName(software.getName());
|
|
|
|
if (StringUtils.equals(serviceSoftwareName, softwareName))
|
|
|
|
{
|
|
|
|
result.add(service);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-25 04:36:38 +02:00
|
|
|
/**
|
|
|
|
* Reverse.
|
|
|
|
*
|
|
|
|
* @return the services
|
|
|
|
*/
|
|
|
|
public Services reverse()
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
Collections.reverse(this);
|
|
|
|
|
|
|
|
result = this;
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort.
|
|
|
|
*
|
|
|
|
* @param sorting
|
|
|
|
* the sorting
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Services sort(final ServiceComparator.Sorting sorting)
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
sort(new ServiceComparator(sorting));
|
|
|
|
|
|
|
|
result = this;
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort by name.
|
|
|
|
*
|
|
|
|
* @return the services
|
|
|
|
*/
|
|
|
|
public Services sortByName()
|
|
|
|
{
|
|
|
|
Services result;
|
|
|
|
|
|
|
|
result = sort(ServiceComparator.Sorting.NAME);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-09-15 03:16:26 +02:00
|
|
|
}
|