org.richfaces.cdk.apt
Interface SourceUtils

All Known Implementing Classes:
AptSourceUtils, ReflectionUtils

public interface SourceUtils

This class provides utility methods to analayze java classes. This implementation uses APT API to get information about Java code.

Author:
asmirnov@exadel.com

Nested Class Summary
static interface SourceUtils.BeanProperty
          

static interface SourceUtils.SuperTypeVisitor
          

 
Method Summary
 javax.lang.model.element.TypeElement asTypeElement(ClassName type)
          

 javax.lang.model.element.TypeElement asTypeElement(javax.lang.model.type.TypeMirror mirror)
          

Converts TypeMirror into corresponding TypeElement

 java.util.Set<SourceUtils.BeanProperty> getAbstractBeanProperties(javax.lang.model.element.TypeElement type)
          

 javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          

Get model representation of the annotation for given model element

<T> T
getAnnotationValue(javax.lang.model.element.AnnotationMirror annotation, java.lang.String propertyName, java.lang.Class<T> expectedType)
          

<T> java.util.List<T>
getAnnotationValues(javax.lang.model.element.AnnotationMirror annotation, java.lang.String propertyName, java.lang.Class<T> expectedType)
          

 java.util.Set<SourceUtils.BeanProperty> getBeanPropertiesAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, javax.lang.model.element.TypeElement type)
          

Get all fields and bean properties that are annotated with given annotation.

 java.lang.Object getConstant(javax.lang.model.element.TypeElement element, java.lang.String name)
          

 java.lang.String getDocComment(javax.lang.model.element.Element element)
          

Get JavaDoc comments associated with given element.

 boolean isAnnotationPresent(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          

Check model element for presense of annotation.

 boolean isAnnotationPropertyPresent(javax.lang.model.element.AnnotationMirror annotation, java.lang.String propertyName)
           
 boolean isDefaultValue(javax.lang.model.element.AnnotationMirror annotation, java.lang.String propertyName)
          

Check annotation proprrty for default value.

 void setModelProperty(java.lang.Object model, javax.lang.model.element.AnnotationMirror annotation, java.lang.String modelProperty)
           
 void setModelProperty(java.lang.Object model, javax.lang.model.element.AnnotationMirror annotation, java.lang.String modelProperty, java.lang.String annotationAttribute)
           
 void visitSupertypes(javax.lang.model.element.TypeElement type, SourceUtils.SuperTypeVisitor visitor)
          

 

Method Detail

getBeanPropertiesAnnotatedWith

java.util.Set<SourceUtils.BeanProperty> getBeanPropertiesAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
                                                                       javax.lang.model.element.TypeElement type)

Get all fields and bean properties that are annotated with given annotation.

Parameters:
annotation -
type -
Returns:

getAbstractBeanProperties

java.util.Set<SourceUtils.BeanProperty> getAbstractBeanProperties(javax.lang.model.element.TypeElement type)

Parameters:
type -
Returns:

getDocComment

java.lang.String getDocComment(javax.lang.model.element.Element element)

Get JavaDoc comments associated with given element.

Parameters:
componentElement -
Returns:

isAnnotationPresent

boolean isAnnotationPresent(javax.lang.model.element.Element element,
                            java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)

Check model element for presense of annotation.

Parameters:
element -
annotationType -
Returns:

getAnnotationMirror

javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.Element element,
                                                              java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)

Get model representation of the annotation for given model element

Parameters:
annotationType -
Returns:

getAnnotationValue

<T> T getAnnotationValue(javax.lang.model.element.AnnotationMirror annotation,
                         java.lang.String propertyName,
                         java.lang.Class<T> expectedType)

Parameters:
annotation -
propertyName -
Returns:

getAnnotationValues

<T> java.util.List<T> getAnnotationValues(javax.lang.model.element.AnnotationMirror annotation,
                                          java.lang.String propertyName,
                                          java.lang.Class<T> expectedType)

Parameters:
annotation -
propertyName -
Returns:

isDefaultValue

boolean isDefaultValue(javax.lang.model.element.AnnotationMirror annotation,
                       java.lang.String propertyName)

Check annotation proprrty for default value.

Parameters:
annotation -
propertyName -
Returns:
true if property has its default value.

getConstant

java.lang.Object getConstant(javax.lang.model.element.TypeElement element,
                             java.lang.String name)

Parameters:
componentElement -
name -
Returns:

visitSupertypes

void visitSupertypes(javax.lang.model.element.TypeElement type,
                     SourceUtils.SuperTypeVisitor visitor)

Parameters:
type -
visitor -

asTypeElement

javax.lang.model.element.TypeElement asTypeElement(javax.lang.model.type.TypeMirror mirror)

Converts TypeMirror into corresponding TypeElement

Parameters:
mirror -
Returns:

asTypeElement

javax.lang.model.element.TypeElement asTypeElement(ClassName type)

Parameters:
type -
Returns:

isAnnotationPropertyPresent

boolean isAnnotationPropertyPresent(javax.lang.model.element.AnnotationMirror annotation,
                                    java.lang.String propertyName)

setModelProperty

void setModelProperty(java.lang.Object model,
                      javax.lang.model.element.AnnotationMirror annotation,
                      java.lang.String modelProperty,
                      java.lang.String annotationAttribute)

setModelProperty

void setModelProperty(java.lang.Object model,
                      javax.lang.model.element.AnnotationMirror annotation,
                      java.lang.String modelProperty)


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.