com.nervousync.commons.query.PartialCollection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nervousync-utils Show documentation
Show all versions of nervousync-utils Show documentation
Java Utils collections, development by Nervousync Studio (NSYC)
/*
* Copyright © 2003 Nervousync Studio, Inc. All rights reserved.
* This software is the confidential and proprietary information of
* Nervousync Studio, Inc. You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with Nervousync Studio.
*/
package com.nervousync.commons.query;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.nervousync.commons.core.Globals;
import com.nervousync.interceptor.beans.BaseHandlerInterceptor;
import com.nervousync.utils.ObjectUtils;
import com.nervousync.utils.ReflectionUtils;
import com.nervousync.utils.StringUtils;
/**
* @author Steven Wee [email protected]
* @version $Revision: 1.0 $ $Date: Jan 13, 2010 4:07:14 PM $
*/
public final class PartialCollection implements Serializable {
/**
* Serial Version UID
*/
private static final long serialVersionUID = 2086690645677391624L;
/**
* Collection of entities (part of some another collection)
*/
private List resultList;
/**
* Total number of elements in collection this collection is part of
*/
private long totalCount;
/**
* Creates an empty instance of PartialCollection
*/
public PartialCollection() {
this(new ArrayList(), 0);
}
/**
* Creates new instance of PartialCollection with specified collection and total
*
* @param collection Part of some collection of entities
* @param total Total size of collection, which part is contained in this instance
*/
public PartialCollection(List resultList, long totalCount) {
this.resultList = resultList;
this.totalCount = totalCount;
}
public List asList() {
return this.resultList;
}
/**
* Gets the size of part of initial collection that is contained here
*
* @return number of elements in partial collection
*/
public int size() {
return this.resultList.size();
}
/**
* Clears the partial collection
*/
public void clear() {
this.resultList.clear();
}
/**
* Figures out is partial collection empty
*
* @return true
if this collection is empty
*/
public boolean isEmpty() {
return this.resultList.isEmpty();
}
public Object[] toArray() {
return this.resultList.toArray();
}
public boolean add(T o) {
return this.resultList.add(o);
}
public boolean contains(Map o) {
return this.resultList.contains(o);
}
public boolean remove(Map o) {
return this.resultList.remove(o);
}
public boolean addAll(Collection c) {
return this.resultList.addAll(c);
}
public boolean containsAll(Collection