Package com.google.inject.internal
Class PackageNameCompressor
- java.lang.Object
-
- com.google.inject.internal.PackageNameCompressor
-
final class PackageNameCompressor extends java.lang.ObjectMunges an error message to remove/shorten package names and adds a legend at the end.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternCLASSNAME_PATTERN(package private) static java.lang.StringLEGEND_FOOTER(package private) static java.lang.StringLEGEND_HEADERprivate static com.google.common.base.JoinerPACKAGE_JOINERprivate static com.google.common.base.SplitterPACKAGE_SPLITTERprivate static com.google.common.collect.ImmutableSet<java.lang.String>PACKAGES_SKIPPED_IN_LEGENDprivate static java.util.regex.PatternQUOTED_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description privatePackageNameCompressor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringbuildClassNameLegend(java.util.Map<java.lang.String,java.lang.String> replacementMap)(package private) static java.lang.StringcompressPackagesInMessage(java.lang.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<java.lang.String>replaceFullNames(java.lang.String input, java.util.Map<java.lang.String,java.lang.String> replacementMap, java.lang.StringBuilder output)Replaces full class names ininputand append the replaced content tooutputand then returns a set of short names that were used as replacement.private static java.util.Map<java.lang.String,java.lang.String>shortenNames(java.util.Collection<java.lang.String> names)Returns a map from short name to full name after resolving conflicts.
-
-
-
Field Detail
-
LEGEND_HEADER
static final java.lang.String LEGEND_HEADER
- See Also:
- Constant Field Values
-
LEGEND_FOOTER
static final java.lang.String LEGEND_FOOTER
- See Also:
- Constant Field Values
-
PACKAGES_SKIPPED_IN_LEGEND
private static final com.google.common.collect.ImmutableSet<java.lang.String> 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
private static final java.util.regex.Pattern CLASSNAME_PATTERN
-
QUOTED_PATTERN
private static final java.util.regex.Pattern QUOTED_PATTERN
-
-
Method Detail
-
compressPackagesInMessage
static java.lang.String compressPackagesInMessage(java.lang.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.
-
replaceFullNames
private static com.google.common.collect.ImmutableSet<java.lang.String> replaceFullNames(java.lang.String input, java.util.Map<java.lang.String,java.lang.String> replacementMap, java.lang.StringBuilder output)Replaces full class names ininputand append the replaced content tooutputand then returns a set of short names that were used as replacement.String literals that are quoted in the
inputwill be added to theoutputunchanged. So any full class name that only appear in the string literal will not be included in the returned short names set.
-
buildClassNameLegend
private static java.lang.String buildClassNameLegend(java.util.Map<java.lang.String,java.lang.String> replacementMap)
-
shortenNames
private static java.util.Map<java.lang.String,java.lang.String> shortenNames(java.util.Collection<java.lang.String> names)
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.
-
-