public final class ElementSource extends Object
declaring source refers to a location in
source code that defines the Guice
element. For example, if
the element is created from a method annotated by @Provides, the
declaring source of element would be the method itself.
getStackTrace() refers to the sequence of calls ends at one of
bindXXX() methods and eventually
defines the element. Note that
StackTraceElements in reverse chronological order.
The first element (index zero) is the last method call and the last element
is the first method invocation. By default, the stack trace is not collected.
The default behavior can be changed by setting the
guice_include_stack_traces flag value. The value can be either
COMPLETE. Note that
collecting stack traces for every binding can cause a performance hit when
the injector is created.
The sequence of class names of
involved in the element creation can be retrieved by
getModuleClassNames(). Similar to
order is reverse chronological. The first module (index 0) is the module that
element. The last module is the root module.
In order to support the cases where a Guice
created from another Guice
element (original) (e.g., by
Element.applyTo(com.google.inject.Binder)), it also provides a reference to the original
element source (
|Modifier and Type||Method and Description|
Returns a single location in source code that defines the element.
Returns the class names of modules involved in creating this
Returns the sequence of method calls that ends at one of
public ElementSource getOriginalElementSource()
ElementSourceof the element this was created or copied from. If this was not created or copied from another element, returns
public Object getDeclaringSource()
Element. The first element (index 0) is the class name of module that defined the element, and the last element is the class name of root module.
configure(Binder)method call in the
stack tracefor modules that their classes returned by
getModuleClassNames(). For example, if the stack trace looks like the following:
0 - Binder.bind(),
1 - ModuleTwo.configure(),
2 - Binder.install(),
3 - ModuleOne.configure(),
4 - theRest().
1 and 3 are returned.
In the cases where stack trace is not available (i.e., the stack trace was not collected), it returns -1 for all module positions.
public StackTraceElement getStackTrace()
bindXXX()methods and eventually defines the element. Note that
StackTraceElementsin reverse chronological order. The first element (index zero) is the last method call and the last element is the first method invocation. In the cases where stack trace is not available (i.e.,the stack trace was not collected), it returns an empty array.