1 /* 2 * Copyright 2007 Joachim Grueneis 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.util.Set; 20 21 import org.castor.core.nature.BaseNature; 22 import org.castor.core.nature.PropertyHolder; 23 24 /** 25 * An AnnotationProcessingService handles multiple {@link AnnotationProcessor}s 26 * and uses them to process one or more {@link Annotation}s. 27 * 28 * @see AnnotationProcessor 29 * @author Alexander Eibner, Peter Schmidt, Joachim Grueneis 30 * @since 1.3 31 */ 32 public interface AnnotationProcessingService { 33 34 /** 35 * Calls {@link #processAnnotation(BaseNature, Annotation)} for each given 36 * Annotation. 37 * 38 * @param info 39 * the {@link BaseNature} (and so its {@link PropertyHolder}) 40 * that should be filled with the information read 41 * @param annotations 42 * the annotations to process 43 * @return Annotation[] filled with unprocessed annotations 44 * @see #processAnnotation(BaseNature, Annotation) 45 */ 46 public abstract <I extends BaseNature> Annotation[] processAnnotations( 47 I info, final Annotation[] annotations); 48 49 /** 50 * The processing action of this service. If an annotation is given which is 51 * not supported by this processor false is returned. Otherwise the 52 * Annotations specific processor will (try to) process the Annotation and 53 * the result of 54 * {@link AnnotationProcessor#processAnnotation(BaseNature, Annotation)} is 55 * returned. 56 * 57 * @param info 58 * the {@link BaseNature} (and so its {@link PropertyHolder}) 59 * that should be filled with the information read 60 * @param annotation 61 * the annotation to process 62 * @return true, if the annotation was processed, false if not 63 * @see AnnotationProcessor 64 */ 65 public <I extends BaseNature, A extends Annotation> boolean processAnnotation( 66 I info, final A annotation); 67 68 /** 69 * Add an {@link AnnotationProcessor} to the service. 70 * 71 * @param annotationProcessor 72 * the {@link AnnotationProcessor} to add to this service. 73 */ 74 public void addAnnotationProcessor( 75 final AnnotationProcessor annotationProcessor); 76 77 /** 78 * Returns the set of {@link AnnotationProcessor}s registered with 79 * this service. 80 * @return A set of {@link AnnotationProcessor}s registered with this service. 81 */ 82 public Set<AnnotationProcessor> getAnnotationProcessors(); 83 84 }