117 /**
118 * Returns {@code null} since a module is not enclosed by another
119 * element.
120 *
121 * @return {@code null}
122 */
123 @Override
124 Element getEnclosingElement();
125
126 /**
127 * Returns the directives contained in the declaration of this module.
128 * @return the directives in the declaration of this module
129 */
130 List<? extends Directive> getDirectives();
131
132 /**
133 * The {@code kind} of a directive.
134 *
135 * <p>Note that it is possible additional directive kinds will be added
136 * to accommodate new, currently unknown, language structures added to
137 * future versions of the Java™ programming language.
138 *
139 * @since 9
140 * @spec JPMS
141 */
142 enum DirectiveKind {
143 /** A "requires (static|transitive)* module-name" directive. */
144 REQUIRES,
145 /** An "exports package-name [to module-name-list]" directive. */
146 EXPORTS,
147 /** An "opens package-name [to module-name-list]" directive. */
148 OPENS,
149 /** A "uses service-name" directive. */
150 USES,
151 /** A "provides service-name with implementation-name" directive. */
152 PROVIDES
153 };
154
155 /**
156 * Represents a directive within the declaration of this
157 * module. The directives of a module declaration configure the
196 * @return a visitor-specified result
197 */
198 <R, P> R accept(DirectiveVisitor<R, P> v, P p);
199 }
200
201 /**
202 * A visitor of module directives, in the style of the visitor design
203 * pattern. Classes implementing this interface are used to operate
204 * on a directive when the kind of directive is unknown at compile time.
205 * When a visitor is passed to a directive's {@link Directive#accept
206 * accept} method, the <code>visit<i>Xyz</i></code> method applicable
207 * to that directive is invoked.
208 *
209 * <p> Classes implementing this interface may or may not throw a
210 * {@code NullPointerException} if the additional parameter {@code p}
211 * is {@code null}; see documentation of the implementing class for
212 * details.
213 *
214 * <p> <b>WARNING:</b> It is possible that methods will be added to
215 * this interface to accommodate new, currently unknown, language
216 * structures added to future versions of the Java™ programming
217 * language. Methods to accommodate new language constructs will
218 * be added in a source <em>compatible</em> way using
219 * <em>default methods</em>.
220 *
221 * @param <R> the return type of this visitor's methods. Use {@link
222 * Void} for visitors that do not need to return results.
223 * @param <P> the type of the additional parameter to this visitor's
224 * methods. Use {@code Void} for visitors that do not need an
225 * additional parameter.
226 *
227 * @since 9
228 * @spec JPMS
229 */
230 interface DirectiveVisitor<R, P> {
231 /**
232 * Visits any directive as if by passing itself to that
233 * directive's {@link Directive#accept accept} method and passing
234 * {@code null} for the additional parameter.
235 *
236 * @param d the directive to visit
|
117 /**
118 * Returns {@code null} since a module is not enclosed by another
119 * element.
120 *
121 * @return {@code null}
122 */
123 @Override
124 Element getEnclosingElement();
125
126 /**
127 * Returns the directives contained in the declaration of this module.
128 * @return the directives in the declaration of this module
129 */
130 List<? extends Directive> getDirectives();
131
132 /**
133 * The {@code kind} of a directive.
134 *
135 * <p>Note that it is possible additional directive kinds will be added
136 * to accommodate new, currently unknown, language structures added to
137 * future versions of the Java programming language.
138 *
139 * @since 9
140 * @spec JPMS
141 */
142 enum DirectiveKind {
143 /** A "requires (static|transitive)* module-name" directive. */
144 REQUIRES,
145 /** An "exports package-name [to module-name-list]" directive. */
146 EXPORTS,
147 /** An "opens package-name [to module-name-list]" directive. */
148 OPENS,
149 /** A "uses service-name" directive. */
150 USES,
151 /** A "provides service-name with implementation-name" directive. */
152 PROVIDES
153 };
154
155 /**
156 * Represents a directive within the declaration of this
157 * module. The directives of a module declaration configure the
196 * @return a visitor-specified result
197 */
198 <R, P> R accept(DirectiveVisitor<R, P> v, P p);
199 }
200
201 /**
202 * A visitor of module directives, in the style of the visitor design
203 * pattern. Classes implementing this interface are used to operate
204 * on a directive when the kind of directive is unknown at compile time.
205 * When a visitor is passed to a directive's {@link Directive#accept
206 * accept} method, the <code>visit<i>Xyz</i></code> method applicable
207 * to that directive is invoked.
208 *
209 * <p> Classes implementing this interface may or may not throw a
210 * {@code NullPointerException} if the additional parameter {@code p}
211 * is {@code null}; see documentation of the implementing class for
212 * details.
213 *
214 * <p> <b>WARNING:</b> It is possible that methods will be added to
215 * this interface to accommodate new, currently unknown, language
216 * structures added to future versions of the Java programming
217 * language. Methods to accommodate new language constructs will
218 * be added in a source <em>compatible</em> way using
219 * <em>default methods</em>.
220 *
221 * @param <R> the return type of this visitor's methods. Use {@link
222 * Void} for visitors that do not need to return results.
223 * @param <P> the type of the additional parameter to this visitor's
224 * methods. Use {@code Void} for visitors that do not need an
225 * additional parameter.
226 *
227 * @since 9
228 * @spec JPMS
229 */
230 interface DirectiveVisitor<R, P> {
231 /**
232 * Visits any directive as if by passing itself to that
233 * directive's {@link Directive#accept accept} method and passing
234 * {@code null} for the additional parameter.
235 *
236 * @param d the directive to visit
|