• 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.Injector;
20 import com.google.inject.Key;
21 import java.util.List;
22 import java.util.Set;
23 
24 /**
25  * A private collection of elements that are hidden from the enclosing injector or module by
26  * default. See {@link com.google.inject.PrivateModule PrivateModule} for details.
27  *
28  * @author jessewilson@google.com (Jesse Wilson)
29  * @since 2.0
30  */
31 public interface PrivateElements extends Element {
32 
33   /** Returns the configuration information in this private environment. */
getElements()34   List<Element> getElements();
35 
36   /**
37    * Returns the child injector that hosts these private elements, or null if the elements haven't
38    * been used to create an injector.
39    */
getInjector()40   Injector getInjector();
41 
42   /** Returns the unique exposed keys for these private elements. */
getExposedKeys()43   Set<Key<?>> getExposedKeys();
44 
45   /**
46    * Returns an arbitrary object containing information about the "place" where this key was
47    * exposed. Used by Guice in the production of descriptive error messages.
48    *
49    * <p>Tools might specially handle types they know about; {@code StackTraceElement} is a good
50    * example. Tools should simply call {@code toString()} on the source object if the type is
51    * unfamiliar.
52    *
53    * @param key one of the keys exposed by this module.
54    */
getExposedSource(Key<?> key)55   Object getExposedSource(Key<?> key);
56 }
57