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

net.anotheria.anoprise.dualcrud.QueryResult Maven / Gradle / Ivy

Go to download

Collection of utils for different enterprise class projects. Among other stuff contains Caches, Mocking, DualCrud, MetaFactory and SessionDistributorService. Visit https://opensource.anotheria.net for details.

There is a newer version: 4.0.0
Show newest version
package net.anotheria.anoprise.dualcrud;

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

public class QueryResult implements Serializable {

	/**
	 * Basic serialVersionUID variable.
	 */
	private static final long serialVersionUID = 4138579115416433003L;

	private List primaryResult;

	private List secondaryResult;

	public QueryResult(List primary, List secondary) {
		if (primary != null)
			this.primaryResult = primary;
		else
			this.primaryResult = new ArrayList();

		if (secondary != null)
			this.secondaryResult = secondary;
		else
			this.secondaryResult = new ArrayList();
	}

	public List getResult(boolean merge) {
		if (!merge)
			return getResultPrimary();

		return merge();

	}

	public List getResultPrimary() {
		return new ArrayList(primaryResult);
	}

	public List getResultSecondary() {
		return new ArrayList(secondaryResult);
	}

	private List merge() {
		Set result = new HashSet(primaryResult);
		for (T o : secondaryResult)
			if (!result.contains(o))
				result.add(o);

		return new ArrayList(result);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy