public class ReflectionHelper extends Object
ReflectionHelper
is an internal class that provides common routines
only used by the annotation processors.Constructor and Description |
---|
ReflectionHelper(ProcessingEnvironment environment,
TypeElement classRepresenter) |
Modifier and Type | Method and Description |
---|---|
Collection<VariableElement> |
filterConstantFields(Collection<VariableElement> fieldElements) |
Collection<VariableElement> |
filterFields(Collection<VariableElement> fieldElements,
Class<? extends Annotation>... annotations)
Returns only fields which are not annotated with one of the passed annotation.
|
Collection<VariableElement> |
filterFields(Collection<VariableElement> fieldElements,
Modifier... modifiers)
Returns only fields which do not contain one of the passed modifiers.
|
Collection<VariableElement> |
filterFields(Collection<VariableElement> fieldElements,
String... simpleFieldNames)
Returns only fields which simple names do not equal the passed field names.
|
Collection<VariableElement> |
getAnnotatedFields(Class<? extends Annotation>... annotations)
Returns all fields annotated with the passed annotation classes.
|
String |
getClassName()
Returns the class name.
|
TypeElement |
getClassRepresenter() |
Collection<VariableElement> |
getConstantFields()
Returns all fields ordered that are
Modifier.FINAL or Modifier.STATIC . |
protected Elements |
getElementUtils()
Utility method.
|
Collection<VariableElement> |
getFields()
Returns all fields.
|
Collection<VariableElement> |
getFinalFields()
Returns all fields which contains
Modifier.FINAL . |
Collection<VariableElement> |
getInFields()
Returns all fields annotated with @
In . |
Collection<VariableElement> |
getModifierFields(Modifier... modifiers)
Returns all fields with the passed modifier.
|
Collection<VariableElement> |
getNonConstantFields()
Returns all fields that are not
Modifier.FINAL or
Modifier.STATIC . |
Collection<VariableElement> |
getOptionalFields()
Returns all non constant fields annotated with @
Optional . |
Collection<VariableElement> |
getOptionalFields(Class<? extends Annotation> annotation)
Returns all non constant fields annotated with passed annotation.
|
Collection<VariableElement> |
getOrderedFields()
Returns all fields ordered.
|
Collection<VariableElement> |
getOutFields()
Returns all fields annotated with @
Out . |
String |
getPackageName() |
ProcessingEnvironment |
getProcessingEnvironment() |
Collection<VariableElement> |
getRequiredFields()
|
String |
getSimpleClassName() |
Collection<VariableElement> |
getStaticFields()
Returns all fields which contains
Modifier.STATIC . |
boolean |
hasOptionalFields() |
boolean |
hasRequiredFields() |
Collection<VariableElement> |
sortFields(Class<? extends Annotation> annotation,
Collection<VariableElement> fields)
Sorts the passed fields based on the passed annotation sort logic.
|
protected void |
sortInFields(SortedMap<Integer,VariableElement> sortedFields,
Collection<VariableElement> fields) |
protected void |
sortOrderFields(SortedMap<Integer,VariableElement> sortedFields,
Collection<VariableElement> fields) |
protected void |
sortOutFields(SortedMap<Integer,VariableElement> sortedFields,
Collection<VariableElement> fields) |
public ReflectionHelper(ProcessingEnvironment environment, TypeElement classRepresenter)
public Collection<VariableElement> filterConstantFields(Collection<VariableElement> fieldElements)
public Collection<VariableElement> filterFields(Collection<VariableElement> fieldElements, Class<? extends Annotation>... annotations)
public Collection<VariableElement> filterFields(Collection<VariableElement> fieldElements, Modifier... modifiers)
public Collection<VariableElement> filterFields(Collection<VariableElement> fieldElements, String... simpleFieldNames)
public Collection<VariableElement> getAnnotatedFields(Class<? extends Annotation>... annotations)
public String getClassName()
For example:
com.gwtplatform.dispatch.annotation.Foo
public TypeElement getClassRepresenter()
public Collection<VariableElement> getConstantFields()
Modifier.FINAL
or Modifier.STATIC
.public Collection<VariableElement> getFields()
Important: Fields are not sorted according to @Order
!
getOrderedFields()
.public Collection<VariableElement> getFinalFields()
Modifier.FINAL
.public Collection<VariableElement> getInFields()
public Collection<VariableElement> getModifierFields(Modifier... modifiers)
public Collection<VariableElement> getNonConstantFields()
Modifier.FINAL
or
Modifier.STATIC
. Sorted based on the @ Order
annotation.public Collection<VariableElement> getOptionalFields()
public Collection<VariableElement> getOptionalFields(Class<? extends Annotation> annotation)
Important: Fields are not sorted!
public Collection<VariableElement> getOrderedFields()
Order
annotation.public Collection<VariableElement> getOutFields()
public String getPackageName()
public ProcessingEnvironment getProcessingEnvironment()
public Collection<VariableElement> getRequiredFields()
Optional
|Modifier.STATIC
|
Modifier.FINAL
fields ordered. Sorted based on the @
Order
annotation.
Required are all:
Optional
fieldsModifier.STATIC
fieldsModifier.FINAL
fieldspublic String getSimpleClassName()
public Collection<VariableElement> getStaticFields()
Modifier.STATIC
.public Collection<VariableElement> sortFields(Class<? extends Annotation> annotation, Collection<VariableElement> fields)
public boolean hasOptionalFields()
public boolean hasRequiredFields()
protected Elements getElementUtils()
protected void sortInFields(SortedMap<Integer,VariableElement> sortedFields, Collection<VariableElement> fields)
protected void sortOrderFields(SortedMap<Integer,VariableElement> sortedFields, Collection<VariableElement> fields)
protected void sortOutFields(SortedMap<Integer,VariableElement> sortedFields, Collection<VariableElement> fields)
Copyright © 2010–2014 Arcbees. All rights reserved.