src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java

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

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

8000663: clean up langtools imports
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 2005, 2012, 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.util;
duke@1 27
duke@1 28
duke@1 29 import javax.lang.model.element.*;
duke@1 30
duke@1 31 import static javax.lang.model.SourceVersion.*;
duke@1 32 import javax.lang.model.SourceVersion;
duke@1 33 import javax.annotation.processing.SupportedSourceVersion;
duke@1 34
duke@1 35 /**
duke@1 36 * A skeletal visitor for annotation values with default behavior
duke@1 37 * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
duke@1 38 * source version.
duke@1 39 *
duke@1 40 * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
duke@1 41 * implemented by this class may have methods added to it in the
duke@1 42 * future to accommodate new, currently unknown, language structures
duke@1 43 * added to future versions of the Java&trade; programming language.
duke@1 44 * Therefore, methods whose names begin with {@code "visit"} may be
duke@1 45 * added to this class in the future; to avoid incompatibilities,
duke@1 46 * classes which extend this class should not declare any instance
duke@1 47 * methods with names beginning with {@code "visit"}.
duke@1 48 *
duke@1 49 * <p>When such a new visit method is added, the default
duke@1 50 * implementation in this class will be to call the {@link
duke@1 51 * #visitUnknown visitUnknown} method. A new abstract annotation
duke@1 52 * value visitor class will also be introduced to correspond to the
duke@1 53 * new language level; this visitor will have different default
duke@1 54 * behavior for the visit method in question. When the new visitor is
duke@1 55 * introduced, all or portions of this visitor may be deprecated.
duke@1 56 *
duke@1 57 * @param <R> the return type of this visitor's methods
duke@1 58 * @param <P> the type of the additional parameter to this visitor's methods.
duke@1 59 *
duke@1 60 * @author Joseph D. Darcy
duke@1 61 * @author Scott Seligman
duke@1 62 * @author Peter von der Ah&eacute;
darcy@575 63 *
darcy@575 64 * @see AbstractAnnotationValueVisitor7
darcy@1054 65 * @see AbstractAnnotationValueVisitor8
duke@1 66 * @since 1.6
duke@1 67 */
duke@1 68 @SupportedSourceVersion(RELEASE_6)
duke@1 69 public abstract class AbstractAnnotationValueVisitor6<R, P>
duke@1 70 implements AnnotationValueVisitor<R, P> {
duke@1 71
duke@1 72 /**
duke@1 73 * Constructor for concrete subclasses to call.
duke@1 74 */
duke@1 75 protected AbstractAnnotationValueVisitor6() {}
duke@1 76
duke@1 77 /**
duke@1 78 * Visits an annotation value as if by passing itself to that
duke@1 79 * value's {@link AnnotationValue#accept accept}. The invocation
duke@1 80 * {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}.
duke@1 81 * @param av {@inheritDoc}
duke@1 82 * @param p {@inheritDoc}
duke@1 83 */
duke@1 84 public final R visit(AnnotationValue av, P p) {
duke@1 85 return av.accept(this, p);
duke@1 86 }
duke@1 87
duke@1 88 /**
duke@1 89 * Visits an annotation value as if by passing itself to that
duke@1 90 * value's {@link AnnotationValue#accept accept} method passing
duke@1 91 * {@code null} for the additional parameter. The invocation
duke@1 92 * {@code v.visit(av)} is equivalent to {@code av.accept(v,
duke@1 93 * null)}.
duke@1 94 * @param av {@inheritDoc}
duke@1 95 */
duke@1 96 public final R visit(AnnotationValue av) {
duke@1 97 return av.accept(this, null);
duke@1 98 }
duke@1 99
duke@1 100 /**
duke@1 101 * {@inheritDoc}
duke@1 102 *
duke@1 103 * <p>The default implementation of this method in {@code
duke@1 104 * AbstractAnnotationValueVisitor6} will always throw {@code
duke@1 105 * UnknownAnnotationValueException}. This behavior is not
duke@1 106 * required of a subclass.
duke@1 107 *
duke@1 108 * @param av {@inheritDoc}
duke@1 109 * @param p {@inheritDoc}
duke@1 110 */
duke@1 111 public R visitUnknown(AnnotationValue av, P p) {
duke@1 112 throw new UnknownAnnotationValueException(av, p);
duke@1 113 }
duke@1 114 }

mercurial