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.Scope; 20 import java.lang.annotation.Annotation; 21 22 /** 23 * No-op visitor for subclassing. All interface methods simply delegate to {@link #visitOther()}, 24 * returning its result. 25 * 26 * @param <V> any type to be returned by the visit method. Use {@link Void} with {@code return null} 27 * if no return type is needed. 28 * @author jessewilson@google.com (Jesse Wilson) 29 * @since 2.0 30 */ 31 public class DefaultBindingScopingVisitor<V> implements BindingScopingVisitor<V> { 32 33 /** Default visit implementation. Returns {@code null}. */ visitOther()34 protected V visitOther() { 35 return null; 36 } 37 38 @Override visitEagerSingleton()39 public V visitEagerSingleton() { 40 return visitOther(); 41 } 42 43 @Override visitScope(Scope scope)44 public V visitScope(Scope scope) { 45 return visitOther(); 46 } 47 48 @Override visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation)49 public V visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation) { 50 return visitOther(); 51 } 52 53 @Override visitNoScoping()54 public V visitNoScoping() { 55 return visitOther(); 56 } 57 } 58