Wed, 06 Apr 2011 19:30:57 -0700
7033809: Rename "disjunctive" to "union" in javax.lang.model
Reviewed-by: mcimadamore, jjg
1 /*
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.source.util;
28 import com.sun.source.tree.*;
30 /**
31 * A simple visitor for tree nodes.
32 *
33 * @author Peter von der Ahé
34 * @since 1.6
35 */
36 public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
37 protected final R DEFAULT_VALUE;
39 protected SimpleTreeVisitor() {
40 DEFAULT_VALUE = null;
41 }
43 protected SimpleTreeVisitor(R defaultValue) {
44 DEFAULT_VALUE = defaultValue;
45 }
47 protected R defaultAction(Tree node, P p) {
48 return DEFAULT_VALUE;
49 }
51 public final R visit(Tree node, P p) {
52 return (node == null) ? null : node.accept(this, p);
53 }
55 public final R visit(Iterable<? extends Tree> nodes, P p) {
56 R r = null;
57 if (nodes != null)
58 for (Tree node : nodes)
59 r = visit(node, p);
60 return r;
61 }
63 public R visitCompilationUnit(CompilationUnitTree node, P p) {
64 return defaultAction(node, p);
65 }
67 public R visitImport(ImportTree node, P p) {
68 return defaultAction(node, p);
69 }
71 public R visitClass(ClassTree node, P p) {
72 return defaultAction(node, p);
73 }
75 public R visitMethod(MethodTree node, P p) {
76 return defaultAction(node, p);
77 }
79 public R visitVariable(VariableTree node, P p) {
80 return defaultAction(node, p);
81 }
83 public R visitEmptyStatement(EmptyStatementTree node, P p) {
84 return defaultAction(node, p);
85 }
87 public R visitBlock(BlockTree node, P p) {
88 return defaultAction(node, p);
89 }
91 public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
92 return defaultAction(node, p);
93 }
95 public R visitWhileLoop(WhileLoopTree node, P p) {
96 return defaultAction(node, p);
97 }
99 public R visitForLoop(ForLoopTree node, P p) {
100 return defaultAction(node, p);
101 }
103 public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
104 return defaultAction(node, p);
105 }
107 public R visitLabeledStatement(LabeledStatementTree node, P p) {
108 return defaultAction(node, p);
109 }
111 public R visitSwitch(SwitchTree node, P p) {
112 return defaultAction(node, p);
113 }
115 public R visitCase(CaseTree node, P p) {
116 return defaultAction(node, p);
117 }
119 public R visitSynchronized(SynchronizedTree node, P p) {
120 return defaultAction(node, p);
121 }
123 public R visitTry(TryTree node, P p) {
124 return defaultAction(node, p);
125 }
127 public R visitCatch(CatchTree node, P p) {
128 return defaultAction(node, p);
129 }
131 public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
132 return defaultAction(node, p);
133 }
135 public R visitIf(IfTree node, P p) {
136 return defaultAction(node, p);
137 }
139 public R visitExpressionStatement(ExpressionStatementTree node, P p) {
140 return defaultAction(node, p);
141 }
143 public R visitBreak(BreakTree node, P p) {
144 return defaultAction(node, p);
145 }
147 public R visitContinue(ContinueTree node, P p) {
148 return defaultAction(node, p);
149 }
151 public R visitReturn(ReturnTree node, P p) {
152 return defaultAction(node, p);
153 }
155 public R visitThrow(ThrowTree node, P p) {
156 return defaultAction(node, p);
157 }
159 public R visitAssert(AssertTree node, P p) {
160 return defaultAction(node, p);
161 }
163 public R visitMethodInvocation(MethodInvocationTree node, P p) {
164 return defaultAction(node, p);
165 }
167 public R visitNewClass(NewClassTree node, P p) {
168 return defaultAction(node, p);
169 }
171 public R visitNewArray(NewArrayTree node, P p) {
172 return defaultAction(node, p);
173 }
175 public R visitParenthesized(ParenthesizedTree node, P p) {
176 return defaultAction(node, p);
177 }
179 public R visitAssignment(AssignmentTree node, P p) {
180 return defaultAction(node, p);
181 }
183 public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
184 return defaultAction(node, p);
185 }
187 public R visitUnary(UnaryTree node, P p) {
188 return defaultAction(node, p);
189 }
191 public R visitBinary(BinaryTree node, P p) {
192 return defaultAction(node, p);
193 }
195 public R visitTypeCast(TypeCastTree node, P p) {
196 return defaultAction(node, p);
197 }
199 public R visitInstanceOf(InstanceOfTree node, P p) {
200 return defaultAction(node, p);
201 }
203 public R visitArrayAccess(ArrayAccessTree node, P p) {
204 return defaultAction(node, p);
205 }
207 public R visitMemberSelect(MemberSelectTree node, P p) {
208 return defaultAction(node, p);
209 }
211 public R visitIdentifier(IdentifierTree node, P p) {
212 return defaultAction(node, p);
213 }
215 public R visitLiteral(LiteralTree node, P p) {
216 return defaultAction(node, p);
217 }
219 public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
220 return defaultAction(node, p);
221 }
223 public R visitArrayType(ArrayTypeTree node, P p) {
224 return defaultAction(node, p);
225 }
227 public R visitParameterizedType(ParameterizedTypeTree node, P p) {
228 return defaultAction(node, p);
229 }
231 public R visitUnionType(UnionTypeTree node, P p) {
232 return defaultAction(node, p);
233 }
235 public R visitTypeParameter(TypeParameterTree node, P p) {
236 return defaultAction(node, p);
237 }
239 public R visitWildcard(WildcardTree node, P p) {
240 return defaultAction(node, p);
241 }
243 public R visitModifiers(ModifiersTree node, P p) {
244 return defaultAction(node, p);
245 }
247 public R visitAnnotation(AnnotationTree node, P p) {
248 return defaultAction(node, p);
249 }
251 public R visitErroneous(ErroneousTree node, P p) {
252 return defaultAction(node, p);
253 }
255 public R visitOther(Tree node, P p) {
256 return defaultAction(node, p);
257 }
258 }