blob: 844a4cbb578a930ccc104af14e2f13b413f949b8 [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
17
18package com.google.inject.spi;
19
20import com.google.inject.Binding;
21
22/**
23 * No-op visitor for subclassing. All interface methods simply delegate to
24 * {@link #visitElement(Element)}, returning its result.
25 *
limpbizkit00ca9f72008-08-02 17:56:17 +000026 * @param <V> any type to be returned by the visit method. Use {@link Void} with
27 * {@code return null} if no return type is needed.
28 *
limpbizkit477f9f92008-07-28 07:05:14 +000029 * @author sberlin@gmail.com (Sam Berlin)
30 */
limpbizkitafa4b5d2008-08-02 18:40:47 +000031public abstract class DefaultElementVisitor<V> implements ElementVisitor<V> {
limpbizkit477f9f92008-07-28 07:05:14 +000032
33 protected DefaultElementVisitor() {}
34
35 /**
36 * Visit {@code element} and return a result.
37 */
38 protected V visitElement(Element element) {
39 return null;
40 }
41
42 public V visitMessage(Message message) {
43 return visitElement(message);
44 }
45
46 public <T> V visitBinding(Binding<T> command) {
47 return visitElement(command);
48 }
49
limpbizkit00ca9f72008-08-02 17:56:17 +000050 public V visitInterceptorBinding(InterceptorBinding command) {
limpbizkit477f9f92008-07-28 07:05:14 +000051 return visitElement(command);
52 }
53
limpbizkit00ca9f72008-08-02 17:56:17 +000054 public V visitScopeBinding(ScopeBinding command) {
limpbizkit477f9f92008-07-28 07:05:14 +000055 return visitElement(command);
56 }
57
limpbizkit00ca9f72008-08-02 17:56:17 +000058 public V visitTypeConverterBinding(TypeConverterBinding command) {
limpbizkit477f9f92008-07-28 07:05:14 +000059 return visitElement(command);
60 }
61
limpbizkit00ca9f72008-08-02 17:56:17 +000062 public <T> V visitProviderLookup(ProviderLookup<T> command) {
limpbizkit477f9f92008-07-28 07:05:14 +000063 return visitElement(command);
64 }
65
limpbizkit00ca9f72008-08-02 17:56:17 +000066 public V visitInjectionRequest(InjectionRequest command) {
limpbizkit477f9f92008-07-28 07:05:14 +000067 return visitElement(command);
68 }
69
limpbizkit00ca9f72008-08-02 17:56:17 +000070 public V visitStaticInjectionRequest(StaticInjectionRequest command) {
limpbizkit477f9f92008-07-28 07:05:14 +000071 return visitElement(command);
72 }
73}