Commit bdfa81df authored by Matija Obreza's avatar Matija Obreza

Display pending buckets, push buckets older than 30s

- TimedList tracks when list is populated with first element
parent 0dc669d3
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.anno.gui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
/**
* The Class TimedList.
*
* @param <T> the generic type
*/
public class TimedList<T> extends ArrayList<T> {
private static final long serialVersionUID = 2721716147790325499L;
private Date created = null;
public TimedList() {
}
@Override
public void clear() {
created = null;
super.clear();
}
@Override
public boolean add(T e) {
if (created == null) {
created = new Date();
}
return super.add(e);
}
@Override
public boolean addAll(Collection<? extends T> c) {
if (created == null) {
created = new Date();
}
return super.addAll(c);
}
@Override
public void add(int index, T element) {
if (created == null) {
created = new Date();
}
super.add(index, element);
}
@Override
public boolean addAll(int index, Collection<? extends T> c) {
if (created == null) {
created = new Date();
}
return super.addAll(index, c);
}
public Date getCreated() {
return created;
}
public boolean isOlderThanSeconds(int seconds) {
if (created == null) {
return true;
}
return (new Date().getTime() - created.getTime()) / 1000 > seconds;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment