View Javadoc

1   /*
2    * Grapht, an open source dependency injector.
3    * Copyright 2014-2015 various contributors (see CONTRIBUTORS.txt)
4    * Copyright 2010-2014 Regents of the University of Minnesota
5    *
6    * This program is free software; you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as
8    * published by the Free Software Foundation; either version 2.1 of the
9    * License, or (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14   * details.
15   *
16   * You should have received a copy of the GNU General Public License along with
17   * this program; if not, write to the Free Software Foundation, Inc., 51
18   * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19   */
20  package org.grouplens.grapht.reflect;
21  
22  import javax.inject.Provider;
23  
24  /**
25   * An interface for visiting {@link Satisfaction}s.
26   *
27   * @param <T> The type returned from this satisfaction's values.
28   * @author <a href="http://grouplens.org">GroupLens Research</a>
29   * @since 0.5
30   * @see Satisfaction
31   */
32  public interface SatisfactionVisitor<T> {
33      /**
34       * Called when visiting a null satisfaction.
35       *
36       * @return The return value.
37       */
38      T visitNull();
39  
40      /**
41       * Called when visiting a satisfaction that will instantiate a class.
42       *
43       * @param clazz The implementation class.
44       * @return The return value.
45       */
46      T visitClass(Class<?> clazz);
47  
48      /**
49       * Called when visiting a satisfaction that will return a pre-configured instance.
50       *
51       * @param instance The instance that will be returned.  The visitor should not modify it
52       *                 in any way.
53       * @return The return value.
54       */
55      T visitInstance(Object instance);
56  
57      /**
58       * Called when visiting a satisfaction that will instantiate and invoke a provider class.
59       *
60       * @param pclass The provider class.
61       * @return The return value.
62       */
63      T visitProviderClass(Class<? extends Provider<?>> pclass);
64  
65      /**
66       * Called when visiting a satisfaction that will invoke a pre-instantiated provider.
67       *
68       * @param provider The provider instance.  The visitor should not modify it in any way.
69       * @return The return value.
70       */
71      T visitProviderInstance(Provider<?> provider);
72  }