1 /* 2 * Copyright 2009 Werner Guttmann 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package org.castor.core.annotationprocessing; 15 16 import java.lang.annotation.Annotation; 17 import java.lang.reflect.AnnotatedElement; 18 import java.util.Set; 19 20 import org.castor.core.nature.BaseNature; 21 import org.castor.core.nature.PropertyHolder; 22 23 /** 24 * Extension of {@link AnnotationProcessingService} to handle target-aware {@link Annotation}s. 25 * 26 * @see AnnotationProcessingService 27 * @author Alexander Eibner, Peter Schmidt 28 * @since 1.3.1 29 */ 30 public interface TargetAwareAnnotationProcessingService extends AnnotationProcessingService { 31 32 /** 33 * Calls {@link #processAnnotation(BaseNature, Annotation)} for each given Annotation. 34 * 35 * @param info the {@link BaseNature} (and so its {@link PropertyHolder}) that should be filled 36 * with the information read 37 * @param annotations the annotations to process 38 * @param target the target ({@link AnnotatedElement}) of the given annotation 39 * @return Annotation[] filled with unprocessed annotations 40 * @throws AnnotationTargetException if an annotation is used in a context that is not valid. 41 * @see #processAnnotation(BaseNature, Annotation) 42 */ 43 public abstract <I extends BaseNature> Annotation[] processAnnotations(I info, 44 final Annotation[] annotations, final AnnotatedElement target) 45 throws AnnotationTargetException; 46 47 /** 48 * The processing action of this service. If an annotation is given which is not supported by this 49 * processor false is returned. Otherwise the Annotations specific processor will (try to) process 50 * the Annotation and the result of 51 * {@link TargetAwareAnnotationProcessor#processAnnotation(BaseNature, Annotation, AnnotatedElement)} 52 * is returned. 53 * 54 * @param info the {@link BaseNature} (and so its {@link PropertyHolder}) that should be filled 55 * with the information read 56 * @param annotation the annotation to process 57 * @param target the target ({@link AnnotatedElement}) of the given annotation 58 * @return true, if the annotation was processed, false if not 59 * @throws AnnotationTargetException if an annotation is used in a context that is not valid. 60 * @see TargetAwareAnnotationProcessor 61 */ 62 public <I extends BaseNature, A extends Annotation> boolean processAnnotation(I info, 63 final A annotation, final AnnotatedElement target) throws AnnotationTargetException; 64 65 /** 66 * Add an {@link TargetAwareAnnotationProcessor} to the service. 67 * 68 * @param annotationProcessor the {@link TargetAwareAnnotationProcessor} to add to this service. 69 */ 70 public void addAnnotationProcessor(final TargetAwareAnnotationProcessor annotationProcessor); 71 72 /** 73 * Returns the set of {@link TargetAwareAnnotationProcessor}s registered with this service. 74 * 75 * @return A set of {@link TargetAwareAnnotationProcessor}s registered with this service. 76 */ 77 public Set<TargetAwareAnnotationProcessor> getTargetAwareAnnotationProcessors(); 78 79 /** 80 * Returns the set of {@link AnnotationProcessor}s and {@link TargetAwareAnnotationProcessor}s 81 * registered with this service. 82 * 83 * @return A set of {@link AnnotationProcessor}s registered with this service. 84 */ 85 public Set<AnnotationProcessor> getAllAnnotationProcessors(); 86 87 }