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 {@link 23 * #visitOther(Element)}, returning its result. 24 * 25 * @param <V> any type to be returned by the visit method. Use {@link Void} with {@code return null} 26 * if no return type is needed. 27 * @author sberlin@gmail.com (Sam Berlin) 28 * @since 2.0 29 */ 30 public abstract class DefaultElementVisitor<V> implements ElementVisitor<V> { 31 32 /** Default visit implementation. Returns {@code null}. */ visitOther(Element element)33 protected V visitOther(Element element) { 34 return null; 35 } 36 37 @Override visit(Message message)38 public V visit(Message message) { 39 return visitOther(message); 40 } 41 42 @Override visit(Binding<T> binding)43 public <T> V visit(Binding<T> binding) { 44 return visitOther(binding); 45 } 46 47 /*if[AOP]*/ 48 @Override visit(InterceptorBinding interceptorBinding)49 public V visit(InterceptorBinding interceptorBinding) { 50 return visitOther(interceptorBinding); 51 } 52 /*end[AOP]*/ 53 54 @Override visit(ScopeBinding scopeBinding)55 public V visit(ScopeBinding scopeBinding) { 56 return visitOther(scopeBinding); 57 } 58 59 @Override visit(TypeConverterBinding typeConverterBinding)60 public V visit(TypeConverterBinding typeConverterBinding) { 61 return visitOther(typeConverterBinding); 62 } 63 64 @Override visit(ProviderLookup<T> providerLookup)65 public <T> V visit(ProviderLookup<T> providerLookup) { 66 return visitOther(providerLookup); 67 } 68 69 @Override visit(InjectionRequest<?> injectionRequest)70 public V visit(InjectionRequest<?> injectionRequest) { 71 return visitOther(injectionRequest); 72 } 73 74 @Override visit(StaticInjectionRequest staticInjectionRequest)75 public V visit(StaticInjectionRequest staticInjectionRequest) { 76 return visitOther(staticInjectionRequest); 77 } 78 79 @Override visit(PrivateElements privateElements)80 public V visit(PrivateElements privateElements) { 81 return visitOther(privateElements); 82 } 83 84 @Override visit(MembersInjectorLookup<T> lookup)85 public <T> V visit(MembersInjectorLookup<T> lookup) { 86 return visitOther(lookup); 87 } 88 89 @Override visit(TypeListenerBinding binding)90 public V visit(TypeListenerBinding binding) { 91 return visitOther(binding); 92 } 93 94 @Override visit(ProvisionListenerBinding binding)95 public V visit(ProvisionListenerBinding binding) { 96 return visitOther(binding); 97 } 98 99 @Override visit(DisableCircularProxiesOption option)100 public V visit(DisableCircularProxiesOption option) { 101 return visitOther(option); 102 } 103 104 @Override visit(RequireExplicitBindingsOption option)105 public V visit(RequireExplicitBindingsOption option) { 106 return visitOther(option); 107 } 108 109 @Override visit(RequireAtInjectOnConstructorsOption option)110 public V visit(RequireAtInjectOnConstructorsOption option) { 111 return visitOther(option); 112 } 113 114 @Override visit(RequireExactBindingAnnotationsOption option)115 public V visit(RequireExactBindingAnnotationsOption option) { 116 return visitOther(option); 117 } 118 119 @Override visit(ModuleAnnotatedMethodScannerBinding binding)120 public V visit(ModuleAnnotatedMethodScannerBinding binding) { 121 return visitOther(binding); 122 } 123 } 124