View Javadoc
1   /*
2    * Copyright 2009 Werner Guttmann
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.castor.core.annotationprocessing;
17  
18  import java.lang.annotation.Annotation;
19  import java.lang.reflect.AnnotatedElement;
20  import java.lang.reflect.Field;
21  
22  import org.castor.core.nature.BaseNature;
23  
24  /**
25   * The interface each specific target-aware annotation processor has to fulfill.
26   * 
27   * @see AnnotationProcessor
28   * @author Alexander Eibner, Peter Schmidt
29   * @since 1.3.1
30   */
31  public interface TargetAwareAnnotationProcessor extends AnnotationProcessor {
32  
33      /**
34       * The processing action of this processor. If an annotation is given which
35       * is not supported false is returned.
36       * 
37       * @param info
38       *            the Info class that should be filled with the information read
39       * @param annotation
40       *            the annotation to process
41       * @param target
42       *            the target ({@link Field}, {@link Class}, etc.) of the given
43       *            annotation
44       * @return true, if the annotation was processed successfully, false if not
45       * @throws AnnotationTargetException
46       *             if an annotation is used in a context that is not valid.
47       * @see AnnotatedElement
48       */
49      <I extends BaseNature, A extends Annotation> boolean processAnnotation(
50              I info, final A annotation, final AnnotatedElement target)
51              throws AnnotationTargetException;
52  
53  }