1 /* 2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.mirror.apt; 27 28 import com.sun.mirror.apt.*; 29 import java.util.*; 30 31 /** 32 * Utilities to create specialized annotation processors. 33 * 34 * @deprecated All components of this API have been superseded by the 35 * standardized annotation processing API. There is no direct analog 36 * of the functionality of this class in the standardized API. 37 * 38 * @since 1.5 39 * @author Joseph D. Darcy 40 * @author Scott Seligman 41 */ 42 @Deprecated 43 @SuppressWarnings("deprecation") 44 public class AnnotationProcessors { 45 static class NoOpAP implements AnnotationProcessor { 46 NoOpAP() {} 47 public void process(){} 48 } 49 50 /** 51 * Combines multiple annotation processors into a simple composite 52 * processor. 53 * The composite processor functions by invoking each of its component 54 * processors in sequence. 55 */ 56 static class CompositeAnnotationProcessor implements AnnotationProcessor { 57 58 private List<AnnotationProcessor> aps = 59 new LinkedList<AnnotationProcessor>(); 60 61 /** 62 * Constructs a new composite annotation processor. 63 * @param aps the component annotation processors 64 */ 65 public CompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) { 66 this.aps.addAll(aps); 67 } 68 69 /** 70 * Constructs a new composite annotation processor. 71 * @param aps the component annotation processors 72 */ 73 public CompositeAnnotationProcessor(AnnotationProcessor... aps) { 74 for(AnnotationProcessor ap: aps) 75 this.aps.add(ap); 76 } 77 78 /** 79 * Invokes the <tt>process</tt> method of each component processor, 80 * in the order in which the processors were passed to the constructor. 81 */ 82 public void process() { 83 for(AnnotationProcessor ap: aps) 84 ap.process(); 85 } 86 } 87 88 89 /** 90 * An annotation processor that does nothing and has no state. 91 * May be used multiple times. 92 * 93 * @since 1.5 94 */ 95 public final static AnnotationProcessor NO_OP = new NoOpAP(); 96 97 /** 98 * Constructs a new composite annotation processor. A composite 99 * annotation processor combines multiple annotation processors 100 * into one and functions by invoking each of its component 101 * processors' process methods in sequence. 102 * 103 * @param aps The processors to create a composite of 104 * @since 1.5 105 */ 106 public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) { 107 return new CompositeAnnotationProcessor(aps); 108 } 109 110 /** 111 * Constructs a new composite annotation processor. A composite 112 * annotation processor combines multiple annotation processors 113 * into one and functions by invoking each of its component 114 * processors' process methods in the sequence the processors are 115 * returned by the collection's iterator. 116 * 117 * @param aps A collection of processors to create a composite of 118 * @since 1.5 119 */ 120 public static AnnotationProcessor getCompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) { 121 return new CompositeAnnotationProcessor(aps); 122 } 123 }