< prev index next >

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

Print this page




 184      * this interface to accommodate new, currently unknown, language
 185      * structures added to future versions of the Java&trade; programming
 186      * language. Methods to accommodate new language constructs will
 187      * be added in a source <em>compatible</em> way using
 188      * <em>default methods</em>.
 189      *
 190      * @param <R> the return type of this visitor's methods.  Use {@link
 191      *            Void} for visitors that do not need to return results.
 192      * @param <P> the type of the additional parameter to this visitor's
 193      *            methods.  Use {@code Void} for visitors that do not need an
 194      *            additional parameter.
 195      *
 196      * @since 9
 197      * @spec JPMS
 198      */
 199     interface DirectiveVisitor<R, P> {
 200         /**
 201          * Visits any directive as if by passing itself to that
 202          * directive's {@link Directive#accept accept} method and passing
 203          * {@code null} for the additional parameter.
 204          * The invocation {@code v.visit(d)} is equivalent to
 205          * {@code d.accept(v, null)}.
 206          * @param d  the directive to visit
 207          * @return a visitor-specified result
 208          * @implSpec This implementation is {@code visit(d, null)}
 209          */
 210         default R visit(Directive d) {
 211             return d.accept(this, null);
 212         }
 213 
 214         /**
 215          * Visits any directive as if by passing itself to that
 216          * directive's {@link Directive#accept accept} method.
 217          * The invocation {@code v.visit(d, p)} is equivalent to
 218          * {@code d.accept(v, p)}.
 219          * @param d  the directive to visit
 220          * @param p  a visitor-specified parameter
 221          * @return a visitor-specified result

 222          */
 223         default R visit(Directive d, P p) {
 224             return d.accept(this, p);
 225         }
 226 
 227         /**
 228          * Visits a {@code requires} directive.
 229          * @param d  the directive to visit
 230          * @param p  a visitor-specified parameter
 231          * @return a visitor-specified result
 232          */
 233         R visitRequires(RequiresDirective d, P p);
 234 
 235         /**
 236          * Visits an {@code exports} directive.
 237          * @param d  the directive to visit
 238          * @param p  a visitor-specified parameter
 239          * @return a visitor-specified result
 240          */
 241         R visitExports(ExportsDirective d, P p);


 254          * @param p  a visitor-specified parameter
 255          * @return a visitor-specified result
 256          */
 257         R visitUses(UsesDirective d, P p);
 258 
 259         /**
 260          * Visits a {@code provides} directive.
 261          * @param d  the directive to visit
 262          * @param p  a visitor-specified parameter
 263          * @return a visitor-specified result
 264          */
 265         R visitProvides(ProvidesDirective d, P p);
 266 
 267         /**
 268          * Visits an unknown directive.
 269          * This can occur if the language evolves and new kinds of directive are added.
 270          * @param d  the directive to visit
 271          * @param p  a visitor-specified parameter
 272          * @return a visitor-specified result
 273          * @throws UnknownDirectiveException a visitor implementation may optionally throw this exception
 274          * @implSpec This implementation throws {@code new UnknownDirectiveException(d, p)}.
 275          */
 276         default R visitUnknown(Directive d, P p) {
 277             throw new UnknownDirectiveException(d, p);
 278         }
 279     }
 280 
 281     /**
 282      * A dependency of a module.
 283      * @since 9
 284      * @spec JPMS
 285      */
 286     interface RequiresDirective extends Directive {
 287         /**
 288          * Returns whether or not this is a static dependency.
 289          * @return whether or not this is a static dependency
 290          */
 291         boolean isStatic();
 292 
 293         /**
 294          * Returns whether or not this is a transitive dependency.




 184      * this interface to accommodate new, currently unknown, language
 185      * structures added to future versions of the Java&trade; programming
 186      * language. Methods to accommodate new language constructs will
 187      * be added in a source <em>compatible</em> way using
 188      * <em>default methods</em>.
 189      *
 190      * @param <R> the return type of this visitor's methods.  Use {@link
 191      *            Void} for visitors that do not need to return results.
 192      * @param <P> the type of the additional parameter to this visitor's
 193      *            methods.  Use {@code Void} for visitors that do not need an
 194      *            additional parameter.
 195      *
 196      * @since 9
 197      * @spec JPMS
 198      */
 199     interface DirectiveVisitor<R, P> {
 200         /**
 201          * Visits any directive as if by passing itself to that
 202          * directive's {@link Directive#accept accept} method and passing
 203          * {@code null} for the additional parameter.
 204          *

 205          * @param d  the directive to visit
 206          * @return a visitor-specified result
 207          * @implSpec The default implementation is {@code d.accept(v, null)}.
 208          */
 209         default R visit(Directive d) {
 210             return d.accept(this, null);
 211         }
 212 
 213         /**
 214          * Visits any directive as if by passing itself to that
 215          * directive's {@link Directive#accept accept} method.
 216          *

 217          * @param d  the directive to visit
 218          * @param p  a visitor-specified parameter
 219          * @return a visitor-specified result
 220          * @implSpec The default implementation is {@code d.accept(v, p)}.
 221          */
 222         default R visit(Directive d, P p) {
 223             return d.accept(this, p);
 224         }
 225 
 226         /**
 227          * Visits a {@code requires} directive.
 228          * @param d  the directive to visit
 229          * @param p  a visitor-specified parameter
 230          * @return a visitor-specified result
 231          */
 232         R visitRequires(RequiresDirective d, P p);
 233 
 234         /**
 235          * Visits an {@code exports} directive.
 236          * @param d  the directive to visit
 237          * @param p  a visitor-specified parameter
 238          * @return a visitor-specified result
 239          */
 240         R visitExports(ExportsDirective d, P p);


 253          * @param p  a visitor-specified parameter
 254          * @return a visitor-specified result
 255          */
 256         R visitUses(UsesDirective d, P p);
 257 
 258         /**
 259          * Visits a {@code provides} directive.
 260          * @param d  the directive to visit
 261          * @param p  a visitor-specified parameter
 262          * @return a visitor-specified result
 263          */
 264         R visitProvides(ProvidesDirective d, P p);
 265 
 266         /**
 267          * Visits an unknown directive.
 268          * This can occur if the language evolves and new kinds of directive are added.
 269          * @param d  the directive to visit
 270          * @param p  a visitor-specified parameter
 271          * @return a visitor-specified result
 272          * @throws UnknownDirectiveException a visitor implementation may optionally throw this exception
 273          * @implSpec The default implementation throws {@code new UnknownDirectiveException(d, p)}.
 274          */
 275         default R visitUnknown(Directive d, P p) {
 276             throw new UnknownDirectiveException(d, p);
 277         }
 278     }
 279 
 280     /**
 281      * A dependency of a module.
 282      * @since 9
 283      * @spec JPMS
 284      */
 285     interface RequiresDirective extends Directive {
 286         /**
 287          * Returns whether or not this is a static dependency.
 288          * @return whether or not this is a static dependency
 289          */
 290         boolean isStatic();
 291 
 292         /**
 293          * Returns whether or not this is a transitive dependency.


< prev index next >