@Override public void setElementType(ObjectType elementType) { this.collectionType = new CollectionTypeImpl(getBaseClass(), elementType); }
public ResultsCollectionWrapper(ObjectType constraint, Collection base) { validateConstraint(constraint); this.base = base; this.collectionType = new CollectionTypeImpl(getBaseClass(), constraint); this.limit = -1; this.hasLimitIterator = false; this.limitImposed = false; }
public ResultsCollectionWrapper(ObjectType constraint, Collection base, int limit) { validateConstraint(constraint); this.base = base; this.collectionType = new CollectionTypeImpl(getBaseClass(), constraint); this.limit = limit; if (this.limit > -1 && this.base.size() > this.limit) { if (this.collectionType.isOrdered()) { this.hasLimitIterator = true; } else { this.hasLimitIterator = false; // Asif:Take only elements upto the limit so that order is predictable // If it is a sorted set it will not come here & so we need not worry // as to truncation happens at end or start int truncate = this.base.size() - limit; synchronized (this.base) { Iterator itr = this.base.iterator(); for (int i = 0; i < truncate; ++i) { itr.next(); itr.remove(); } } } } else { this.hasLimitIterator = false; } this.limitImposed = this.limit > -1; }