Package com.google.inject.internal
Class ChildBindingAlreadySetError
- java.lang.Object
-
- com.google.inject.spi.ErrorDetail<T>
-
- com.google.inject.internal.InternalErrorDetail<ChildBindingAlreadySetError>
-
- com.google.inject.internal.ChildBindingAlreadySetError
-
- All Implemented Interfaces:
java.io.Serializable
final class ChildBindingAlreadySetError extends InternalErrorDetail<ChildBindingAlreadySetError>
Error reported by Guice when a key is already bound in one or more child injectors or private modules.
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<java.lang.Object>
existingSources
private Key<?>
key
-
Fields inherited from class com.google.inject.internal.InternalErrorDetail
errorId
-
-
Constructor Summary
Constructors Constructor Description ChildBindingAlreadySetError(Key<?> key, java.lang.Iterable<java.lang.Object> existingSoruces, java.util.List<java.lang.Object> sources)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
formatDetail(java.util.List<ErrorDetail<?>> mergeableErrors, java.util.Formatter formatter)
Formats the detail of this error message along with other errors that are mergeable with this error.boolean
isMergeable(ErrorDetail<?> otherError)
Returns true if this error can be merged with theotherError
and formatted together.private java.util.List<java.lang.Object>
trimSource(java.util.List<java.lang.Object> sources)
Omit the key itself in the source list since the information is redundant.ChildBindingAlreadySetError
withSources(java.util.List<java.lang.Object> newSources)
Returns a new instance of the sameErrorDetail
with updated sources.-
Methods inherited from class com.google.inject.internal.InternalErrorDetail
getErrorIdentifier, getLearnMoreLink
-
Methods inherited from class com.google.inject.spi.ErrorDetail
equals, format, getCause, getMessage, getSources, hashCode
-
-
-
-
Field Detail
-
key
private final Key<?> key
-
existingSources
private final com.google.common.collect.ImmutableList<java.lang.Object> existingSources
-
-
Constructor Detail
-
ChildBindingAlreadySetError
ChildBindingAlreadySetError(Key<?> key, java.lang.Iterable<java.lang.Object> existingSoruces, java.util.List<java.lang.Object> sources)
-
-
Method Detail
-
isMergeable
public boolean isMergeable(ErrorDetail<?> otherError)
Description copied from class:ErrorDetail
Returns true if this error can be merged with theotherError
and formatted together.By default this return false and implementations that support merging with other errors should override this method.
- Overrides:
isMergeable
in classErrorDetail<ChildBindingAlreadySetError>
-
formatDetail
public void formatDetail(java.util.List<ErrorDetail<?>> mergeableErrors, java.util.Formatter formatter)
Description copied from class:ErrorDetail
Formats the detail of this error message along with other errors that are mergeable with this error. This is called fromErrorDetail.format(int, java.util.List<com.google.inject.spi.ErrorDetail<?>>, java.util.Formatter)
.mergeableErrors
is a list that contains all other errors that are reported in the same exception that are considered to be mergable with this error base on result of callingErrorDetail.isMergeable(com.google.inject.spi.ErrorDetail<?>)
. The list will be empty if non of the other errors are mergable with this error.- Specified by:
formatDetail
in classErrorDetail<ChildBindingAlreadySetError>
- Parameters:
mergeableErrors
- list of errors that are mergeable with this errorformatter
- for printing the error message
-
withSources
public ChildBindingAlreadySetError withSources(java.util.List<java.lang.Object> newSources)
Description copied from class:ErrorDetail
Returns a new instance of the sameErrorDetail
with updated sources.- Specified by:
withSources
in classErrorDetail<ChildBindingAlreadySetError>
-
trimSource
private java.util.List<java.lang.Object> trimSource(java.util.List<java.lang.Object> sources)
Omit the key itself in the source list since the information is redundant.
-
-