Class PackageNameCompressor

java.lang.Object
com.google.inject.internal.PackageNameCompressor

final class PackageNameCompressor extends Object
Munges an error message to remove/shorten package names and adds a legend at the end.
  • Field Details

    • LEGEND_HEADER

      static final String LEGEND_HEADER
      See Also:
    • PACKAGES_SKIPPED_IN_LEGEND

      private static final com.google.common.collect.ImmutableSet<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 Pattern CLASSNAME_PATTERN
    • QUOTED_PATTERN

      private static final Pattern QUOTED_PATTERN
  • Constructor Details

    • PackageNameCompressor

      private PackageNameCompressor()
  • Method Details

    • compressPackagesInMessage

      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.
    • replaceFullNames

      private static com.google.common.collect.ImmutableSet<String> replaceFullNames(String input, Map<String,String> replacementMap, StringBuilder output)
      Replaces full class names in input and append the replaced content to output 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 the output unchanged. 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 String buildClassNameLegend(Map<String,String> replacementMap)
    • shortenNames

      private static Map<String,String> shortenNames(Collection<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.