< prev index next >

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

Print this page




  51  *
  52  * <p> <b>WARNING:</b> It is possible that methods will be added to
  53  * this interface to accommodate new, currently unknown, language
  54  * structures added to future versions of the Java&trade; programming
  55  * language.  Therefore, visitor classes directly implementing this
  56  * interface may be source incompatible with future versions of the
  57  * platform.  To avoid this source incompatibility, visitor
  58  * implementations are encouraged to instead extend the appropriate
  59  * abstract visitor class that implements this interface.  However, an
  60  * API should generally use this visitor interface as the type for
  61  * parameters, return type, etc. rather than one of the abstract
  62  * classes.
  63  *
  64  * <p>Note that methods to accommodate new language constructs could
  65  * be added in a source <em>compatible</em> way if they were added as
  66  * <em>default methods</em>.  However, default methods are only
  67  * available on Java SE 8 and higher releases and the {@code
  68  * javax.lang.model.*} packages bundled in Java SE 8 were required to
  69  * also be runnable on Java SE 7.  Therefore, default methods
  70  * were <em>not</em> used when extending {@code javax.lang.model.*}
  71  * to cover Java SE 8 language features.  However, default methods may
  72  * be used in subsequent revisions of the {@code javax.lang.model.*}
  73  * packages that are only required to run on Java SE 8 and higher
  74  * platform versions.
  75  *
  76  * @param <R> the return type of this visitor's methods
  77  * @param <P> the type of the additional parameter to this visitor's methods.
  78  * @author Joseph D. Darcy
  79  * @author Scott Seligman
  80  * @author Peter von der Ah&eacute;
  81  * @since 1.6
  82  */
  83 public interface AnnotationValueVisitor<R, P> {
  84     /**
  85      * Visits an annotation value.
  86      * @param av the value to visit
  87      * @param p a visitor-specified parameter
  88      * @return  a visitor-specified result
  89      */
  90     R visit(AnnotationValue av, P p);
  91 
  92     /**
  93      * A convenience method equivalent to {@code v.visit(av, null)}.



  94      * @param av the value to visit
  95      * @return  a visitor-specified result
  96      */
  97     R visit(AnnotationValue av);


  98 
  99     /**
 100      * Visits a {@code boolean} value in an annotation.
 101      * @param b the value being visited
 102      * @param p a visitor-specified parameter
 103      * @return the result of the visit
 104      */
 105     R visitBoolean(boolean b, P p);
 106 
 107     /**
 108      * Visits a {@code byte} value in an annotation.
 109      * @param  b the value being visited
 110      * @param  p a visitor-specified parameter
 111      * @return the result of the visit
 112      */
 113     R visitByte(byte b, P p);
 114 
 115     /**
 116      * Visits a {@code char} value in an annotation.
 117      * @param  c the value being visited




  51  *
  52  * <p> <b>WARNING:</b> It is possible that methods will be added to
  53  * this interface to accommodate new, currently unknown, language
  54  * structures added to future versions of the Java&trade; programming
  55  * language.  Therefore, visitor classes directly implementing this
  56  * interface may be source incompatible with future versions of the
  57  * platform.  To avoid this source incompatibility, visitor
  58  * implementations are encouraged to instead extend the appropriate
  59  * abstract visitor class that implements this interface.  However, an
  60  * API should generally use this visitor interface as the type for
  61  * parameters, return type, etc. rather than one of the abstract
  62  * classes.
  63  *
  64  * <p>Note that methods to accommodate new language constructs could
  65  * be added in a source <em>compatible</em> way if they were added as
  66  * <em>default methods</em>.  However, default methods are only
  67  * available on Java SE 8 and higher releases and the {@code
  68  * javax.lang.model.*} packages bundled in Java SE 8 were required to
  69  * also be runnable on Java SE 7.  Therefore, default methods
  70  * were <em>not</em> used when extending {@code javax.lang.model.*}
  71  * to cover Java SE 8 language features.  However, default methods
  72  * are used in subsequent revisions of the {@code javax.lang.model.*}
  73  * packages that are only required to run on Java SE 8 and higher
  74  * platform versions.
  75  *
  76  * @param <R> the return type of this visitor's methods
  77  * @param <P> the type of the additional parameter to this visitor's methods.
  78  * @author Joseph D. Darcy
  79  * @author Scott Seligman
  80  * @author Peter von der Ah&eacute;
  81  * @since 1.6
  82  */
  83 public interface AnnotationValueVisitor<R, P> {
  84     /**
  85      * Visits an annotation value.
  86      * @param av the value to visit
  87      * @param p a visitor-specified parameter
  88      * @return  a visitor-specified result
  89      */
  90     R visit(AnnotationValue av, P p);
  91 
  92     /**
  93      * A convenience method equivalent to {@code visit(av, null)}.
  94      *
  95      * @implSpec The default implementation is {@code visit(av, null)}.
  96      *
  97      * @param av the value to visit
  98      * @return  a visitor-specified result
  99      */
 100     default R visit(AnnotationValue av) {
 101         return visit(av, null);
 102     }
 103 
 104     /**
 105      * Visits a {@code boolean} value in an annotation.
 106      * @param b the value being visited
 107      * @param p a visitor-specified parameter
 108      * @return the result of the visit
 109      */
 110     R visitBoolean(boolean b, P p);
 111 
 112     /**
 113      * Visits a {@code byte} value in an annotation.
 114      * @param  b the value being visited
 115      * @param  p a visitor-specified parameter
 116      * @return the result of the visit
 117      */
 118     R visitByte(byte b, P p);
 119 
 120     /**
 121      * Visits a {@code char} value in an annotation.
 122      * @param  c the value being visited


< prev index next >