All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.europa.esig.dss.util.MutableTimeDependentValues Maven / Gradle / Ivy

There is a newer version: 6.0.d4j.2
Show newest version
package eu.europa.esig.dss.util;

import java.util.Date;
import java.util.List;

/**
 * Mutable list of time-dependent values.
 * 
 * @author jdvorak
 * @param 
 */
public class MutableTimeDependentValues extends TimeDependentValues {

	public MutableTimeDependentValues() {
		super();
	}

	public MutableTimeDependentValues(final Iterable srcList) {
		super(srcList);
	}

	public synchronized void clear() {
		list.clear();
	}

	public synchronized void addOldest(final T x) {
		if (x == null) {
			throw new NullPointerException("Cannot add null");
		}
		if (!list.isEmpty()) {
			final Date endDate = x.getEndDate();
			for (final T y : list) {
				if (endDate.compareTo(y.getStartDate()) > 0) {
					throw new IllegalArgumentException("Cannot add overlapping item");
				}
			}
		}
		list.add(x);
	}

	public List getList() {
		return list;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy