agirstatool/src/org/april/agirstatool/charts/DateCountList.java

112 lines
2.1 KiB
Java

/*
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* This file is part of AgirStatool, simple key value database.
*
* AgirStatool 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.
*
* AgirStatool 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 AgirStatool. If not, see <http://www.gnu.org/licenses/>.
*/
package org.april.agirstatool.charts;
import java.util.ArrayList;
import org.apache.commons.lang3.StringUtils;
import fr.devinsy.strings.StringList;
/**
* The Class Projects.
*/
public class DateCountList extends ArrayList<DateCount>
{
private static final long serialVersionUID = -5526492552751712533L;
/**
* Instantiates a new date count map.
*/
public DateCountList()
{
super();
}
/**
* Instantiates a new date count list.
*
* @param capacity
* the capacity
*/
public DateCountList(final int capacity)
{
super(capacity);
}
/**
* Indexof.
*
* @param dateToken
* the date token
* @return the int
*/
public int indexOf(final String dateToken)
{
int result;
boolean ended = false;
result = -1;
int index = 0;
while (!ended)
{
if (index < this.size())
{
DateCount current = get(index);
if (StringUtils.equals(current.getDate(), dateToken))
{
ended = true;
result = index;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = -1;
}
}
//
return result;
}
/**
* To value list.
*
* @return the string list
*/
public StringList toValueList()
{
StringList result;
result = new StringList();
for (DateCount item : this)
{
result.append(item.getCount());
}
//
return result;
}
}