1477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit/**
2477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * Copyright (C) 2008 Google Inc.
3477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit *
4477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * Licensed under the Apache License, Version 2.0 (the "License");
5477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * you may not use this file except in compliance with the License.
6477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * You may obtain a copy of the License at
7477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit *
8477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * http://www.apache.org/licenses/LICENSE-2.0
9477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit *
10477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * Unless required by applicable law or agreed to in writing, software
11477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * distributed under the License is distributed on an "AS IS" BASIS,
12477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * See the License for the specific language governing permissions and
14477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * limitations under the License.
15477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit */
16477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit
17477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkitpackage com.google.inject.spi;
18477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit
1903b81a6b931a06c7697e422b218e3734a7f262cclimpbizkitimport com.google.inject.Binder;
2003b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit
21477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit/**
2200ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit * A core component of a module or injector.
2300ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit *
2400ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit * <p>The elements of a module can be inspected, validated and rewritten. Use {@link
25c6c02088d97e46af497db89dd228a689298cd9eblimpbizkit * Elements#getElements(com.google.inject.Module[]) Elements.getElements()} to read the elements
2661584c4284d223bb4d0af1ab56f3c19bdbe7329elimpbizkit * from a module, and {@link Elements#getModule(Iterable) Elements.getModule()} to rewrite them.
2761584c4284d223bb4d0af1ab56f3c19bdbe7329elimpbizkit * This can be used for static analysis and generation of Guice modules.
2800ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit *
2900ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit * <p>The elements of an injector can be inspected and exercised. Use {@link
30c6c02088d97e46af497db89dd228a689298cd9eblimpbizkit * com.google.inject.Injector#getBindings Injector.getBindings()} to reflect on Guice injectors.
31477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit *
32477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit * @author jessewilson@google.com (Jesse Wilson)
3303b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit * @author crazybob@google.com (Bob Lee)
34c489adf4671b41765698d167e13960d998190c5elimpbizkit * @since 2.0
35477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit */
36477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkitpublic interface Element {
3700ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit
3800ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit  /**
3900ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   * Returns an arbitrary object containing information about the "place" where this element was
4000ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   * configured. Used by Guice in the production of descriptive error messages.
4100ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   *
4200ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   * <p>Tools might specially handle types they know about; {@code StackTraceElement} is a good
4300ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   * example. Tools should simply call {@code toString()} on the source object if the type is
4400ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   * unfamiliar.
4500ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit   */
46477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit  Object getSource();
473af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit
483af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit  /**
493af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit   * Accepts an element visitor. Invokes the visitor method specific to this element's type.
503af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit   *
513af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit   * @param visitor to call back on
523af8411e50160885c1bdb5f09468182c02afe3ablimpbizkit   */
53afa4b5dd2056a8427657186d1804313c3f34fbfelimpbizkit  <T> T acceptVisitor(ElementVisitor<T> visitor);
5400ca9f749aa80383ee7d85ad25e1535a79fe5718limpbizkit
5503b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit  /**
5603b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   * Writes this module element to the given binder (optional operation).
5703b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   *
5803b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   * @param binder to apply configuration element to
5903b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   * @throws UnsupportedOperationException if the {@code applyTo} method is not supported by this
6003b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   *     element.
6103b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit   */
6203b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit  void applyTo(Binder binder);
6303b81a6b931a06c7697e422b218e3734a7f262cclimpbizkit
64477f9f9ce3e1077866b579e99cd33ab824f1ee69limpbizkit}
65