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