Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2010-2011 eBusiness Information, Excilys Group Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed To in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package com.googlecode.androidannotations.helper;
 import java.util.Map;
 public class TargetAnnotationHelper extends AnnotationHelper implements HasTarget {
 	private Class<? extends Annotationtarget;
 	public TargetAnnotationHelper(ProcessingEnvironment processingEnvClass<? extends Annotationtarget) {
 		this. = target;
 	public <T> T extractAnnotationValue(Element element) {
 		Annotation annotation = element.getAnnotation();
 		Method method;
 		try {
 			method = annotation.getClass().getMethod("value");
 			return (T) method.invoke(annotation);
 		} catch (Exception e) {
 			throw new RuntimeException(e);
 		AnnotationMirror annotationMirror = findAnnotationMirror(element);
 		Map<? extends ExecutableElement, ? extends AnnotationValueelementValues = annotationMirror.getElementValues();
 		for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValueentry : elementValues.entrySet()) {
 			 * "value" is unset when the default value is used
 			if ("value".equals(entry.getKey().getSimpleName().toString())) {
 				AnnotationValue annotationValue = entry.getValue();
 				DeclaredType annotationClass = (DeclaredTypeannotationValue.getValue();
 				return annotationClass;
 		return null;
 	public Class<? extends AnnotationgetTarget() {
 		return ;
 	public String actionName() {
 		return .getSimpleName() + "ed";
 	public static String annotationName(Class<? extends AnnotationannotationClass) {
 		return "@" + annotationClass.getSimpleName();
 	public String annotationName() {

message if the string contains a %s, it will be replaced with the annotation name (ex: @Override)
 	public void printAnnotationError(Element annotatedElementString message) {
 		printAnnotationError(annotatedElement, String.format(messageannotationName()));

message if the string contains a %s, it will be replaced with the annotation name (ex: @Override)
	public void printAnnotationWarning(Element annotatedElementString message) {
		printAnnotationWarning(annotatedElement, String.format(messageannotationName()));
New to GrepCode? Check out our FAQ X