src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 554
9d9f26857129
child 1522
09f65aad4759
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

duke@1 1 /*
ohair@554 2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package javax.lang.model.element;
duke@1 27
duke@1 28
duke@1 29 import java.util.List;
duke@1 30
duke@1 31 import javax.lang.model.type.TypeMirror;
duke@1 32
duke@1 33
duke@1 34 /**
duke@1 35 * A visitor of the values of annotation type elements, using a
duke@1 36 * variant of the visitor design pattern. Unlike a standard visitor
duke@1 37 * which dispatches based on the concrete type of a member of a type
duke@1 38 * hierarchy, this visitor dispatches based on the type of data
duke@1 39 * stored; there are no distinct subclasses for storing, for example,
duke@1 40 * {@code boolean} values versus {@code int} values. Classes
duke@1 41 * implementing this interface are used to operate on a value when the
duke@1 42 * type of that value is unknown at compile time. When a visitor is
duke@1 43 * passed to a value's {@link AnnotationValue#accept accept} method,
duke@1 44 * the <tt>visit<i>XYZ</i></tt> method applicable to that value is
duke@1 45 * invoked.
duke@1 46 *
duke@1 47 * <p> Classes implementing this interface may or may not throw a
duke@1 48 * {@code NullPointerException} if the additional parameter {@code p}
duke@1 49 * is {@code null}; see documentation of the implementing class for
duke@1 50 * details.
duke@1 51 *
duke@1 52 * <p> <b>WARNING:</b> It is possible that methods will be added to
duke@1 53 * this interface to accommodate new, currently unknown, language
duke@1 54 * structures added to future versions of the Java&trade; programming
duke@1 55 * language. Therefore, visitor classes directly implementing this
duke@1 56 * interface may be source incompatible with future versions of the
duke@1 57 * platform. To avoid this source incompatibility, visitor
duke@1 58 * implementations are encouraged to instead extend the appropriate
duke@1 59 * abstract visitor class that implements this interface. However, an
duke@1 60 * API should generally use this visitor interface as the type for
duke@1 61 * parameters, return type, etc. rather than one of the abstract
duke@1 62 * classes.
duke@1 63 *
duke@1 64 * @param <R> the return type of this visitor's methods
duke@1 65 * @param <P> the type of the additional parameter to this visitor's methods.
duke@1 66 * @author Joseph D. Darcy
duke@1 67 * @author Scott Seligman
duke@1 68 * @author Peter von der Ah&eacute;
duke@1 69 * @since 1.6
duke@1 70 */
duke@1 71 public interface AnnotationValueVisitor<R, P> {
duke@1 72 /**
duke@1 73 * Visits an annotation value.
duke@1 74 * @param av the value to visit
duke@1 75 * @param p a visitor-specified parameter
duke@1 76 * @return a visitor-specified result
duke@1 77 */
duke@1 78 R visit(AnnotationValue av, P p);
duke@1 79
duke@1 80 /**
duke@1 81 * A convenience method equivalent to {@code v.visit(av, null)}.
duke@1 82 * @param av the value to visit
duke@1 83 * @return a visitor-specified result
duke@1 84 */
duke@1 85 R visit(AnnotationValue av);
duke@1 86
duke@1 87 /**
duke@1 88 * Visits a {@code boolean} value in an annotation.
duke@1 89 * @param b the value being visited
duke@1 90 * @param p a visitor-specified parameter
duke@1 91 * @return the result of the visit
duke@1 92 */
duke@1 93 R visitBoolean(boolean b, P p);
duke@1 94
duke@1 95 /**
duke@1 96 * Visits a {@code byte} value in an annotation.
duke@1 97 * @param b the value being visited
duke@1 98 * @param p a visitor-specified parameter
duke@1 99 * @return the result of the visit
duke@1 100 */
duke@1 101 R visitByte(byte b, P p);
duke@1 102
duke@1 103 /**
duke@1 104 * Visits a {@code char} value in an annotation.
duke@1 105 * @param c the value being visited
duke@1 106 * @param p a visitor-specified parameter
duke@1 107 * @return the result of the visit
duke@1 108 */
duke@1 109 R visitChar(char c, P p);
duke@1 110
duke@1 111 /**
duke@1 112 * Visits a {@code double} value in an annotation.
duke@1 113 * @param d the value being visited
duke@1 114 * @param p a visitor-specified parameter
duke@1 115 * @return the result of the visit
duke@1 116 */
duke@1 117 R visitDouble(double d, P p);
duke@1 118
duke@1 119 /**
duke@1 120 * Visits a {@code float} value in an annotation.
duke@1 121 * @param f the value being visited
duke@1 122 * @param p a visitor-specified parameter
duke@1 123 * @return the result of the visit
duke@1 124 */
duke@1 125 R visitFloat(float f, P p);
duke@1 126
duke@1 127 /**
duke@1 128 * Visits an {@code int} value in an annotation.
duke@1 129 * @param i the value being visited
duke@1 130 * @param p a visitor-specified parameter
duke@1 131 * @return the result of the visit
duke@1 132 */
duke@1 133 R visitInt(int i, P p);
duke@1 134
duke@1 135 /**
duke@1 136 * Visits a {@code long} value in an annotation.
duke@1 137 * @param i the value being visited
duke@1 138 * @param p a visitor-specified parameter
duke@1 139 * @return the result of the visit
duke@1 140 */
duke@1 141 R visitLong(long i, P p);
duke@1 142
duke@1 143 /**
duke@1 144 * Visits a {@code short} value in an annotation.
duke@1 145 * @param s the value being visited
duke@1 146 * @param p a visitor-specified parameter
duke@1 147 * @return the result of the visit
duke@1 148 */
duke@1 149 R visitShort(short s, P p);
duke@1 150
duke@1 151 /**
duke@1 152 * Visits a string value in an annotation.
duke@1 153 * @param s the value being visited
duke@1 154 * @param p a visitor-specified parameter
duke@1 155 * @return the result of the visit
duke@1 156 */
duke@1 157 R visitString(String s, P p);
duke@1 158
duke@1 159 /**
duke@1 160 * Visits a type value in an annotation.
duke@1 161 * @param t the value being visited
duke@1 162 * @param p a visitor-specified parameter
duke@1 163 * @return the result of the visit
duke@1 164 */
duke@1 165 R visitType(TypeMirror t, P p);
duke@1 166
duke@1 167 /**
duke@1 168 * Visits an {@code enum} value in an annotation.
duke@1 169 * @param c the value being visited
duke@1 170 * @param p a visitor-specified parameter
duke@1 171 * @return the result of the visit
duke@1 172 */
duke@1 173 R visitEnumConstant(VariableElement c, P p);
duke@1 174
duke@1 175 /**
duke@1 176 * Visits an annotation value in an annotation.
duke@1 177 * @param a the value being visited
duke@1 178 * @param p a visitor-specified parameter
duke@1 179 * @return the result of the visit
duke@1 180 */
duke@1 181 R visitAnnotation(AnnotationMirror a, P p);
duke@1 182
duke@1 183 /**
duke@1 184 * Visits an array value in an annotation.
duke@1 185 * @param vals the value being visited
duke@1 186 * @param p a visitor-specified parameter
duke@1 187 * @return the result of the visit
duke@1 188 */
duke@1 189 R visitArray(List<? extends AnnotationValue> vals, P p);
duke@1 190
duke@1 191 /**
duke@1 192 * Visits an unknown kind of annotation value.
duke@1 193 * This can occur if the language evolves and new kinds
duke@1 194 * of value can be stored in an annotation.
duke@1 195 * @param av the unknown value being visited
duke@1 196 * @param p a visitor-specified parameter
duke@1 197 * @return the result of the visit
duke@1 198 * @throws UnknownAnnotationValueException
duke@1 199 * a visitor implementation may optionally throw this exception
duke@1 200 */
duke@1 201 R visitUnknown(AnnotationValue av, P p);
duke@1 202 }

mercurial