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

gov.nasa.pds.web.ui.containers.dataSet.Bucket Maven / Gradle / Ivy

package gov.nasa.pds.web.ui.containers.dataSet;

import gov.nasa.pds.web.ui.containers.dataSet.ValidationResults.SimpleProblem;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Bucket implements Serializable {

	private static final long serialVersionUID = 1L;

	private static final long DEFAULT_BUCKET_SIZE = 1000;

	private final long bucketSize;

	private boolean full = false;

	private List problems = new ArrayList();

	public Bucket() {
		this(null);
	}

	public Bucket(final Long bucketSize) {
		this.bucketSize = bucketSize == null ? DEFAULT_BUCKET_SIZE : bucketSize;
	}

	public boolean isFull() {
		return this.full;
	}

	public boolean addProblem(final SimpleProblem problem) {
		if (this.full) {
			throw new RuntimeException("Bucket is full"); //$NON-NLS-1$
		}
		this.problems.add(problem);

		this.full = this.problems.size() >= this.bucketSize;
		return this.full;
	}

	public List getProblems() {
		return this.problems;
	}
	
	/**
	 * Gets a count of problems in this bucket.
	 * 
	 * @return the count of problems
	 */
	public int getProblemCount() {
		return this.problems.size();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy