com.google.gwt.inject.rebind.util
Class MemberCollector

java.lang.Object
  extended by com.google.gwt.inject.rebind.util.MemberCollector

public class MemberCollector
extends java.lang.Object

This class can be used to collect a type's members, including those of its (recursive) superclasses and interfaces. The collector treats overrides correctly, i.e. it returns the method defined the closest to the provided type.

Note: The collector uses internal caching and can be called with the same arguments repeatedly without repeated performance costs.

This class is not thread-safe.


Nested Class Summary
static interface MemberCollector.FieldFilter
          Filter used during the collection of fields to restrict the kind of collected fields.
static interface MemberCollector.MethodFilter
          Filter used during the collection of methods to restrict the kind of collected methods.
 
Field Summary
static MemberCollector.MethodFilter ALL_METHOD_FILTER
           
 
Constructor Summary
MemberCollector(com.google.gwt.core.ext.TreeLogger logger)
           
 
Method Summary
 java.util.Collection<FieldLiteral<?>> getFields(TypeLiteral<?> typeLiteral)
          Returns all fields in the provided type, including those of the type's (recursive) super classes.
 java.util.Collection<MethodLiteral<?,java.lang.reflect.Method>> getMethods(TypeLiteral<?> typeLiteral)
          Returns all methods in the provided type, including those of the type's (recursive) super classes and interfaces.
 void setFieldFilter(MemberCollector.FieldFilter filter)
          Sets this collector's field filter.
 void setMethodFilter(MemberCollector.MethodFilter filter)
          Sets this collector's method filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_METHOD_FILTER

public static final MemberCollector.MethodFilter ALL_METHOD_FILTER
Constructor Detail

MemberCollector

@Inject
public MemberCollector(com.google.gwt.core.ext.TreeLogger logger)
Method Detail

setMethodFilter

public void setMethodFilter(MemberCollector.MethodFilter filter)
                     throws java.lang.IllegalStateException
Sets this collector's method filter. This method can only be called before members are requested.

Parameters:
filter - new method filter for this collector
Throws:
java.lang.IllegalStateException - if the filter is set after members have been requested

setFieldFilter

public void setFieldFilter(MemberCollector.FieldFilter filter)
                    throws java.lang.IllegalStateException
Sets this collector's field filter. This method can only be called before members are requested.

Parameters:
filter - new field filter for this collector
Throws:
java.lang.IllegalStateException - if the filter is set after members have been requested

getMethods

public java.util.Collection<MethodLiteral<?,java.lang.reflect.Method>> getMethods(TypeLiteral<?> typeLiteral)
Returns all methods in the provided type, including those of the type's (recursive) super classes and interfaces. Treats overloads correctly. If no method filter is set will return an empty set.

Parameters:
typeLiteral - type for which methods are collected
Returns:
all methods for the given type

getFields

public java.util.Collection<FieldLiteral<?>> getFields(TypeLiteral<?> typeLiteral)
Returns all fields in the provided type, including those of the type's (recursive) super classes. If no field filter is set will return an empty set.

Parameters:
typeLiteral - type for which fields are collected
Returns:
all fields for the given type