T - The type of object accepted by this collectorpublic class Collector<T> extends java.lang.Object implements IQueryResult<T>
false from
its accept(Object) method.
This default collector just accepts all objects passed to it. Clients may subclass to perform different processing on the objects passed to it.
| Modifier and Type | Field and Description |
|---|---|
static Collector<?> |
EMPTY_COLLECTOR |
| Constructor and Description |
|---|
Collector()
Creates a new collector.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(T object)
Accepts an object.
|
void |
addAll(IQueryResult<T> queryResult)
Adds the elements from one collector to this collector
|
static <T> Collector<T> |
emptyCollector() |
protected java.util.Collection<T> |
getCollection()
Returns the collection that is being used to collect results.
|
boolean |
isEmpty()
Returns whether this collector is empty.
|
java.util.Iterator<T> |
iterator()
Returns an iterator on the collected objects.
|
IQueryResult<T> |
query(IQuery<T> query,
IProgressMonitor monitor)
Performs a query on this results of this collector.
|
int |
size()
Returns the number of collected objects.
|
T[] |
toArray(java.lang.Class<T> clazz)
Returns the collected objects as an array
|
java.util.Set<T> |
toSet()
Returns a copy of the collected objects.
|
java.util.Set<T> |
toUnmodifiableSet()
Returns the collected objects as an immutable collection.
|
public static final Collector<?> EMPTY_COLLECTOR
public static final <T> Collector<T> emptyCollector()
public boolean accept(T object)
This default implementation adds the objects to a list. Clients may override this method to perform additional filtering, add different objects to the list, short-circuit the traversal, or process the objects directly without collecting them.
object - the object to collect or visittrue if the traversal should continue,
or false to indicate the traversal should stop.public void addAll(IQueryResult<T> queryResult)
queryResult - The collector from which the elements should be retrievedprotected java.util.Collection<T> getCollection()
public boolean isEmpty()
isEmpty in interface IQueryResult<T>true if this collector has accepted any results,
and false otherwise.public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>iterator in interface IQueryResult<T>public int size()
public T[] toArray(java.lang.Class<T> clazz)
toArray in interface IQueryResult<T>clazz - The type of array to returnjava.lang.ArrayStoreException - the runtime type of the specified array is
not a super-type of the runtime type of every collected objectpublic java.util.Set<T> toSet()
toSet in interface IQueryResult<T>public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor)
query in interface IQueryable<T>query - The query to performmonitor - a progress monitor, or null if progress
reporting is not desiredpublic java.util.Set<T> toUnmodifiableSet()
toUnmodifiableSet in interface IQueryResult<T>
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.