blob: cf8df75a803032c87804f6d51b45603fe15ccfc6 [file] [log] [blame]
limpbizkit477f9f92008-07-28 07:05:14 +00001/**
2 * Copyright (C) 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
limpbizkit477f9f92008-07-28 07:05:14 +000017package com.google.inject.spi;
18
19import com.google.inject.Binding;
20
21/**
22 * No-op visitor for subclassing. All interface methods simply delegate to
limpbizkit03b81a62009-03-18 05:34:39 +000023 * {@link #visitOther(Element)}, returning its result.
limpbizkit477f9f92008-07-28 07:05:14 +000024 *
limpbizkit00ca9f72008-08-02 17:56:17 +000025 * @param <V> any type to be returned by the visit method. Use {@link Void} with
26 * {@code return null} if no return type is needed.
27 *
limpbizkit477f9f92008-07-28 07:05:14 +000028 * @author sberlin@gmail.com (Sam Berlin)
limpbizkitc489adf2008-11-18 07:01:33 +000029 * @since 2.0
limpbizkit477f9f92008-07-28 07:05:14 +000030 */
limpbizkitafa4b5d2008-08-02 18:40:47 +000031public abstract class DefaultElementVisitor<V> implements ElementVisitor<V> {
limpbizkit477f9f92008-07-28 07:05:14 +000032
limpbizkit477f9f92008-07-28 07:05:14 +000033 /**
limpbizkit03b81a62009-03-18 05:34:39 +000034 * Default visit implementation. Returns {@code null}.
limpbizkit477f9f92008-07-28 07:05:14 +000035 */
limpbizkit03b81a62009-03-18 05:34:39 +000036 protected V visitOther(Element element) {
limpbizkit477f9f92008-07-28 07:05:14 +000037 return null;
38 }
39
limpbizkit03b81a62009-03-18 05:34:39 +000040 public V visit(Message message) {
41 return visitOther(message);
limpbizkit477f9f92008-07-28 07:05:14 +000042 }
43
limpbizkit03b81a62009-03-18 05:34:39 +000044 public <T> V visit(Binding<T> binding) {
45 return visitOther(binding);
limpbizkit477f9f92008-07-28 07:05:14 +000046 }
47
limpbizkitbf0d8762009-02-19 09:06:22 +000048 /*if[AOP]*/
limpbizkit03b81a62009-03-18 05:34:39 +000049 public V visit(InterceptorBinding interceptorBinding) {
50 return visitOther(interceptorBinding);
limpbizkit477f9f92008-07-28 07:05:14 +000051 }
limpbizkitbf0d8762009-02-19 09:06:22 +000052 /*end[AOP]*/
limpbizkit477f9f92008-07-28 07:05:14 +000053
limpbizkit03b81a62009-03-18 05:34:39 +000054 public V visit(ScopeBinding scopeBinding) {
55 return visitOther(scopeBinding);
limpbizkit477f9f92008-07-28 07:05:14 +000056 }
57
limpbizkit03b81a62009-03-18 05:34:39 +000058 public V visit(TypeConverterBinding typeConverterBinding) {
59 return visitOther(typeConverterBinding);
limpbizkit477f9f92008-07-28 07:05:14 +000060 }
61
limpbizkit03b81a62009-03-18 05:34:39 +000062 public <T> V visit(ProviderLookup<T> providerLookup) {
63 return visitOther(providerLookup);
limpbizkit477f9f92008-07-28 07:05:14 +000064 }
65
limpbizkit03b81a62009-03-18 05:34:39 +000066 public V visit(InjectionRequest injectionRequest) {
67 return visitOther(injectionRequest);
limpbizkit477f9f92008-07-28 07:05:14 +000068 }
69
limpbizkit03b81a62009-03-18 05:34:39 +000070 public V visit(StaticInjectionRequest staticInjectionRequest) {
71 return visitOther(staticInjectionRequest);
limpbizkit5ea4ab22008-11-25 08:43:49 +000072 }
73
limpbizkit03b81a62009-03-18 05:34:39 +000074 public V visit(PrivateElements privateElements) {
75 return visitOther(privateElements);
76 }
77
78 public <T> V visit(MembersInjectorLookup<T> lookup) {
79 return visitOther(lookup);
80 }
81
limpbizkitee792462009-04-08 23:48:49 +000082 public V visit(TypeListenerBinding binding) {
limpbizkit03b81a62009-03-18 05:34:39 +000083 return visitOther(binding);
limpbizkit5ea4ab22008-11-25 08:43:49 +000084 }
limpbizkit477f9f92008-07-28 07:05:14 +000085}