Top Description Fields Constructors Methods
com.google.inject.spi

public abstract Class ErrorDetail<SelfT extends ErrorDetail<SelfT>>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
com.google.inject.internal.InternalErrorDetail
Imports
com.google.common.base.Objects, com.google.common.collect.ImmutableList, com.google.inject.internal.Messages, java.io.Serializable, java.util.Formatter, .List, .Optional

Details about a single Guice error and supports formatting itself in the context of other Guice errors.

Warning

The class and its APIs are still experimental and subject to change.

Since
5.0

Field Summary

Modifier and TypeField and Description
private final Throwable
private final String
private final ImmutableList<Object>

Constructor Summary

AccessConstructor and Description
protected
ErrorDetail(String message, List<Object> sources, Throwable cause)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public final void
format(int
index for this error
index
,
List<ErrorDetail<?>>
list of errors that are mergeable with this error
mergeableErrors
,
Formatter
for printing the error message
formatter
)

Formats this error along with other errors that are mergeable with this error.

protected abstract void
formatDetail(List<ErrorDetail<?>>
list of errors that are mergeable with this error
mergeableErrors
,
Formatter
for printing the error message
formatter
)

Formats the detail of this error message along with other errors that are mergeable with this error.

public Throwable
protected Optional<String>
getErrorIdentifier()

Returns an optional string identifier for this error.

public String
public List<Object>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
isMergeable(ErrorDetail<?> otherError)

Returns true if this error can be merged with the otherError and formatted together.

public abstract SelfT
withSources(List<Object> newSources)

Returns a new instance of the same ErrorDetail with updated sources.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

causeback to summary
private final Throwable cause
messageback to summary
private final String message
sourcesback to summary
private final ImmutableList<Object> sources

Constructor Detail

ErrorDetailback to summary
protected ErrorDetail(String message, List<Object> sources, Throwable cause)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
formatback to summary
public final void format(int index, List<ErrorDetail<?>> mergeableErrors, Formatter formatter)

Formats this error along with other errors that are mergeable with this error.

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 calling isMergeable. The list will be empty if non of the other errors are mergable with this error.

Formatted error has the following structure:

  • Summary of the error
  • Details about the error such as the source of the error
  • Hints for fixing the error if available
  • Link to the documentation on this error in greater detail
Parameters
index:int

index for this error

mergeableErrors:List<ErrorDetail<?>>

list of errors that are mergeable with this error

formatter:Formatter

for printing the error message

formatDetailback to summary
protected abstract void formatDetail(List<ErrorDetail<?>> mergeableErrors, Formatter formatter)

Formats the detail of this error message along with other errors that are mergeable with this error. This is called from format.

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 calling isMergeable. The list will be empty if non of the other errors are mergable with this error.

Parameters
mergeableErrors:List<ErrorDetail<?>>

list of errors that are mergeable with this error

formatter:Formatter

for printing the error message

getCauseback to summary
public Throwable getCause()
getErrorIdentifierback to summary
protected Optional<String> getErrorIdentifier()

Returns an optional string identifier for this error.

getMessageback to summary
public String getMessage()
getSourcesback to summary
public List<Object> getSources()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isMergeableback to summary
public boolean isMergeable(ErrorDetail<?> otherError)

Returns true if this error can be merged with the otherError and formatted together.

By default this return false and implementations that support merging with other errors should override this method.

withSourcesback to summary
public abstract SelfT withSources(List<Object> newSources)

Returns a new instance of the same ErrorDetail with updated sources.