Package com.google.inject.internal
Class PackageNameCompressor
java.lang.Object
com.google.inject.internal.PackageNameCompressor
Munges an error message to remove/shorten package names and adds a legend at the end.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Pattern
(package private) static final String
(package private) static final String
private static final com.google.common.base.Joiner
private static final com.google.common.base.Splitter
private static final com.google.common.collect.ImmutableSet<String>
private static final Pattern
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
buildClassNameLegend
(Map<String, String> replacementMap) (package private) static String
compressPackagesInMessage
(String input) Compresses an error message by stripping the packages out of class names and adding them to a legend at the bottom of the error.private static com.google.common.collect.ImmutableSet<String>
replaceFullNames
(String input, Map<String, String> replacementMap, StringBuilder output) Replaces full class names ininput
and append the replaced content tooutput
and then returns a set of short names that were used as replacement.shortenNames
(Collection<String> names) Returns a map from short name to full name after resolving conflicts.
-
Field Details
-
LEGEND_HEADER
- See Also:
-
LEGEND_FOOTER
- See Also:
-
PACKAGES_SKIPPED_IN_LEGEND
-
PACKAGE_SPLITTER
private static final com.google.common.base.Splitter PACKAGE_SPLITTER -
PACKAGE_JOINER
private static final com.google.common.base.Joiner PACKAGE_JOINER -
CLASSNAME_PATTERN
-
QUOTED_PATTERN
-
-
Constructor Details
-
PackageNameCompressor
private PackageNameCompressor()
-
-
Method Details
-
compressPackagesInMessage
Compresses an error message by stripping the packages out of class names and adding them to a legend at the bottom of the error. -
replaceFullNames
private static com.google.common.collect.ImmutableSet<String> replaceFullNames(String input, Map<String, String> replacementMap, StringBuilder output) Replaces full class names ininput
and append the replaced content tooutput
and then returns a set of short names that were used as replacement.String literals that are quoted in the
input
will be added to theoutput
unchanged. So any full class name that only appear in the string literal will not be included in the returned short names set. -
buildClassNameLegend
-
shortenNames
Returns a map from short name to full name after resolving conflicts. This resolves conflicts by adding on segments of the package name until they are unique. For example, com.foo.Baz and com.bar.Baz will conflict on Baz and then resolve with foo.Baz and bar.Baz as replacements.
-