1 /** 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 17 package com.google.inject.spi; 18 19 import com.google.inject.Binding; 20 21 /** 22 * No-op visitor for subclassing. All interface methods simply delegate to 23 * {@link #visitOther(Element)}, returning its result. 24 * 25 * @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 * 28 * @author sberlin@gmail.com (Sam Berlin) 29 * @since 2.0 30 */ 31 public abstract class DefaultElementVisitor<V> implements ElementVisitor<V> { 32 33 /** 34 * Default visit implementation. Returns {@code null}. 35 */ visitOther(Element element)36 protected V visitOther(Element element) { 37 return null; 38 } 39 visit(Message message)40 public V visit(Message message) { 41 return visitOther(message); 42 } 43 visit(Binding<T> binding)44 public <T> V visit(Binding<T> binding) { 45 return visitOther(binding); 46 } 47 48 /*if[AOP]*/ visit(InterceptorBinding interceptorBinding)49 public V visit(InterceptorBinding interceptorBinding) { 50 return visitOther(interceptorBinding); 51 } 52 /*end[AOP]*/ 53 visit(ScopeBinding scopeBinding)54 public V visit(ScopeBinding scopeBinding) { 55 return visitOther(scopeBinding); 56 } 57 visit(TypeConverterBinding typeConverterBinding)58 public V visit(TypeConverterBinding typeConverterBinding) { 59 return visitOther(typeConverterBinding); 60 } 61 visit(ProviderLookup<T> providerLookup)62 public <T> V visit(ProviderLookup<T> providerLookup) { 63 return visitOther(providerLookup); 64 } 65 visit(InjectionRequest<?> injectionRequest)66 public V visit(InjectionRequest<?> injectionRequest) { 67 return visitOther(injectionRequest); 68 } 69 visit(StaticInjectionRequest staticInjectionRequest)70 public V visit(StaticInjectionRequest staticInjectionRequest) { 71 return visitOther(staticInjectionRequest); 72 } 73 visit(PrivateElements privateElements)74 public V visit(PrivateElements privateElements) { 75 return visitOther(privateElements); 76 } 77 visit(MembersInjectorLookup<T> lookup)78 public <T> V visit(MembersInjectorLookup<T> lookup) { 79 return visitOther(lookup); 80 } 81 visit(TypeListenerBinding binding)82 public V visit(TypeListenerBinding binding) { 83 return visitOther(binding); 84 } 85 visit(ProvisionListenerBinding binding)86 public V visit(ProvisionListenerBinding binding) { 87 return visitOther(binding); 88 } 89 visit(DisableCircularProxiesOption option)90 public V visit(DisableCircularProxiesOption option) { 91 return visitOther(option); 92 } 93 visit(RequireExplicitBindingsOption option)94 public V visit(RequireExplicitBindingsOption option) { 95 return visitOther(option); 96 } 97 visit(RequireAtInjectOnConstructorsOption option)98 public V visit(RequireAtInjectOnConstructorsOption option) { 99 return visitOther(option); 100 } 101 visit(RequireExactBindingAnnotationsOption option)102 public V visit(RequireExactBindingAnnotationsOption option) { 103 return visitOther(option); 104 } 105 visit(ModuleAnnotatedMethodScannerBinding binding)106 public V visit(ModuleAnnotatedMethodScannerBinding binding) { 107 return visitOther(binding); 108 } 109 } 110