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

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 1522
09f65aad4759
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

duke@1 1 /*
ksrini@2227 2 * Copyright (c) 2005, 2013, 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 *
darcy@1522 57 * <p>Note that adding a default implementation of a new visit method
darcy@1522 58 * in a visitor class will occur instead of adding a <em>default
darcy@1522 59 * method</em> directly in the visitor interface since a Java SE 8
darcy@1522 60 * language feature cannot be used to this version of the API since
darcy@1522 61 * this version is required to be runnable on Java SE 7
darcy@1522 62 * implementations. Future versions of the API that are only required
darcy@1522 63 * to run on Java SE 8 and later may take advantage of default methods
darcy@1522 64 * in this situation.
darcy@1522 65 *
duke@1 66 * @param <R> the return type of this visitor's methods
duke@1 67 * @param <P> the type of the additional parameter to this visitor's methods.
duke@1 68 *
duke@1 69 * @author Joseph D. Darcy
duke@1 70 * @author Scott Seligman
duke@1 71 * @author Peter von der Ah&eacute;
darcy@575 72 *
darcy@575 73 * @see AbstractAnnotationValueVisitor7
darcy@1054 74 * @see AbstractAnnotationValueVisitor8
duke@1 75 * @since 1.6
duke@1 76 */
duke@1 77 @SupportedSourceVersion(RELEASE_6)
duke@1 78 public abstract class AbstractAnnotationValueVisitor6<R, P>
duke@1 79 implements AnnotationValueVisitor<R, P> {
duke@1 80
duke@1 81 /**
duke@1 82 * Constructor for concrete subclasses to call.
duke@1 83 */
duke@1 84 protected AbstractAnnotationValueVisitor6() {}
duke@1 85
duke@1 86 /**
duke@1 87 * Visits an annotation value as if by passing itself to that
duke@1 88 * value's {@link AnnotationValue#accept accept}. The invocation
duke@1 89 * {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}.
duke@1 90 * @param av {@inheritDoc}
duke@1 91 * @param p {@inheritDoc}
duke@1 92 */
duke@1 93 public final R visit(AnnotationValue av, P p) {
duke@1 94 return av.accept(this, p);
duke@1 95 }
duke@1 96
duke@1 97 /**
duke@1 98 * Visits an annotation value as if by passing itself to that
duke@1 99 * value's {@link AnnotationValue#accept accept} method passing
duke@1 100 * {@code null} for the additional parameter. The invocation
duke@1 101 * {@code v.visit(av)} is equivalent to {@code av.accept(v,
duke@1 102 * null)}.
duke@1 103 * @param av {@inheritDoc}
duke@1 104 */
duke@1 105 public final R visit(AnnotationValue av) {
duke@1 106 return av.accept(this, null);
duke@1 107 }
duke@1 108
duke@1 109 /**
duke@1 110 * {@inheritDoc}
duke@1 111 *
duke@1 112 * <p>The default implementation of this method in {@code
duke@1 113 * AbstractAnnotationValueVisitor6} will always throw {@code
duke@1 114 * UnknownAnnotationValueException}. This behavior is not
duke@1 115 * required of a subclass.
duke@1 116 *
duke@1 117 * @param av {@inheritDoc}
duke@1 118 * @param p {@inheritDoc}
duke@1 119 */
duke@1 120 public R visitUnknown(AnnotationValue av, P p) {
duke@1 121 throw new UnknownAnnotationValueException(av, p);
duke@1 122 }
duke@1 123 }

mercurial