T
- The type of object accepted by this collectorpublic class Collector<T> extends 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 Collection<T> |
getCollection()
Returns the collection that is being used to collect results.
|
boolean |
isEmpty()
Returns whether this collector is empty.
|
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(Class<T> clazz)
Returns the collected objects as an array
|
Set<T> |
toSet()
Returns a copy of the collected objects.
|
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 Collection<T> getCollection()
public boolean isEmpty()
isEmpty
in interface IQueryResult<T>
true
if this collector has accepted any results,
and false
otherwise.public int size()
public T[] toArray(Class<T> clazz)
toArray
in interface IQueryResult<T>
clazz
- The type of array to returnArrayStoreException
- the runtime type of the specified array is
not a super-type of the runtime type of every collected objectpublic 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 Set<T> toUnmodifiableSet()
toUnmodifiableSet
in interface IQueryResult<T>
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.