/** * Builds a map of a module's packages and all types anywhere within them, * e.g. if there's two types com.foo.bar.A and com.foo.baz.B, the map will * look like this: "com": {"com.foo.bar.A", "com.foo.baz.B"} "com.foo": * {"com.foo.bar.A", "com.foo.baz.B"}, "com.foo.bar": {"com.foo.bar.A"}, * "com.foo.baz": {"com.foo.baz.B"} All packages that directly contain a * type are added to the given set. * * @param typesInModule the Java types within the module in question * @param typePackages the set to which to add each type's package * @return a non-<code>null</code> map laid out as above */ @SuppressWarnings("unused") private Map<String, Collection<String>> getTypesByPackage(final Iterable<String> typesInModule, final Set<String> typePackages) { final Map<String, Collection<String>> typesByPackage = new HashMap<String, Collection<String>>(); for (final String typeName : typesInModule) { final String typePackage = getPackageFromType(typeName); typePackages.add(typePackage); for (final String discoveredPackage : getAllPackages(typePackage)) { if (typesByPackage.get(discoveredPackage) == null) { typesByPackage.put(discoveredPackage, new HashSet<String>()); } typesByPackage.get(discoveredPackage).add(typeName); } } return typesByPackage; }
final String type = getPackageFromType(typeName); final String[] typeSegments = type.split("\\."); final Set<String> discoveredPackages = new HashSet<String>();
/** * Builds a map of a module's packages and all types anywhere within them, * e.g. if there's two types com.foo.bar.A and com.foo.baz.B, the map will * look like this: "com": {"com.foo.bar.A", "com.foo.baz.B"} "com.foo": * {"com.foo.bar.A", "com.foo.baz.B"}, "com.foo.bar": {"com.foo.bar.A"}, * "com.foo.baz": {"com.foo.baz.B"} All packages that directly contain a * type are added to the given set. * * @param typesInModule the Java types within the module in question * @param typePackages the set to which to add each type's package * @return a non-<code>null</code> map laid out as above */ @SuppressWarnings("unused") private Map<String, Collection<String>> getTypesByPackage(final Iterable<String> typesInModule, final Set<String> typePackages) { final Map<String, Collection<String>> typesByPackage = new HashMap<String, Collection<String>>(); for (final String typeName : typesInModule) { final String typePackage = getPackageFromType(typeName); typePackages.add(typePackage); for (final String discoveredPackage : getAllPackages(typePackage)) { if (typesByPackage.get(discoveredPackage) == null) { typesByPackage.put(discoveredPackage, new HashSet<String>()); } typesByPackage.get(discoveredPackage).add(typeName); } } return typesByPackage; }
final String type = getPackageFromType(typeName); final String[] typeSegments = type.split("\\."); final Set<String> discoveredPackages = new HashSet<String>();