All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.richfaces.cdk.apt.SourceUtils Maven / Gradle / Ivy

The newest version!
/*
 * $Id$
 *
 * License Agreement.
 *
 * Rich Faces - Natural Ajax for Java Server Faces (JSF)
 *
 * Copyright (C) 2007 Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */
package org.richfaces.cdk.apt;

import java.lang.annotation.Annotation;
import java.util.Set;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;

import org.richfaces.cdk.model.ClassName;

import com.google.inject.ProvidedBy;

/**
 * 

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

* * @author [email protected] * */ @ProvidedBy(SourceUtilsProvider.class) public interface SourceUtils { /** *

*

* * @author [email protected] * */ public interface SuperTypeVisitor { void visit(TypeMirror type); } enum ACCESS_TYPE { readOnly, writeOnly, readWrite } /** *

*

* * @author [email protected] * */ public interface BeanProperty { /** *

*

* * @return the name */ String getName(); /** *

* Get JavaDoc comment of appropriate bean property element. *

* * @return */ String getDocComment(); /** *

* Bean property type *

* * @return */ ClassName getType(); /** *

* Is this property implementted by component *

* * @return the exists */ boolean isExists(); boolean isAnnotationPresent(Class annotationType); AnnotationMirror getAnnotationMirror(Class annotationType); T getAnnotation(Class annotationType); ACCESS_TYPE getAccessType(); } /** *

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

* * @param annotation * @param type * @return */ Set getBeanPropertiesAnnotatedWith(Class annotation, TypeElement type); /** *

*

* * @param type * @return */ Set getAbstractBeanProperties(TypeElement type); /** *

* Get bean property descriptor for particular type. *

* * @param type * @param name * @return */ BeanProperty getBeanProperty(TypeElement type, String name); /** *

* Get bean property descriptor for particular type. *

* * @param type * @param name * @return */ BeanProperty getBeanProperty(ClassName type, String name); /** *

* Get JavaDoc comments associated with given element. *

* * @param element * @return */ String getDocComment(Element element); /** *

* Check model element for presense of annotation. *

* * @param element * @param annotationType * @return */ boolean isAnnotationPresent(Element element, Class annotationType); /** *

* Get model representation of the annotation for given model element *

* * @param annotationType * @return */ AnnotationMirror getAnnotationMirror(Element element, Class annotationType); /** *

*

* * @param annotation * @param propertyName * @return */ T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class expectedType); /** *

*

* * @param annotation * @param propertyName * @return */ Iterable getAnnotationValues(AnnotationMirror annotation, String propertyName, Class expectedType); /** *

*

* * @param annotation * @param propertyName * @return */ boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName); /** *

* Check annotation proprrty for default value. *

* * @param annotation * @param propertyName * @return true if property has its default value. */ boolean isDefaultValue(AnnotationMirror annotation, String propertyName); /** *

*

* * @param model * @param annotation * @param modelProperty * @param annotationAttribute */ void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty, String annotationAttribute); /** *

*

* * @param model * @param annotation * @param modelProperty */ void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty); /** *

*

* * @param element * @param name * @return */ Object getConstant(TypeElement element, String name); /** *

*

* * @param type * @param visitor */ void visitSupertypes(TypeElement type, SuperTypeVisitor visitor); /** *

* Converts TypeMirror into corresponding TypeElement *

* * @param mirror * @return The Element for given type */ TypeElement asTypeElement(TypeMirror mirror); /** *

*

* * @param type * @return true if class already exist in project source or dependent libraries. */ boolean isClassExists(ClassName type); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy