net.anotheria.anoprise.dualcrud.QueryResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ano-prise Show documentation
Show all versions of ano-prise Show documentation
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.
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