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