public final class DefaultImportPackages
extends Object
Orders default-import package prefixes by a caller-supplied precedence
array. Iteration order of the returned sets is that array's order.
Packages that are not in the array are dropped, so a HashSet
walk cannot put a later package ahead of an earlier one.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static Set<String> |
including(Set<String> existing, String packagePrefix, String[] precedence)Returns existing when it already contains packagePrefix.
|
|
public static void |
merge(Map<String, Set<String>> target, Map<String, Set<String>> additions, String[] precedence)Unions additions into target. |
|
public static Set<String> |
ordered(Collection<String> packages, String[] precedence)Returns the members of packages that occur in precedence,
iterated in precedence order. |
Returns existing when it already contains packagePrefix.
Otherwise returns the precedence-ordered union. packagePrefix
values absent from precedence are not added.
existing - the packages already recorded, or nullpackagePrefix - the package to addprecedence - package prefixes in try-orderexisting when unchanged Unions additions into target. Each stored set is
rewritten with ordered. An addition that contributes no
precedence package is ignored. When the value already stored contains
every incoming package, that same instance is kept.
target - class name to packages already collected; updated in placeadditions - class name to packages found by one scan; null is a no-opprecedence - package prefixes in try-order Returns the members of packages that occur in precedence,
iterated in precedence order. Matches are inserted into a
LinkedHashSet while walking precedence, then wrapped.
The wrapper stays: callers publish the set to concurrent readers and
share it with the startup index, so a later update replaces the map
entry instead of mutating this set.
An empty result is Collections.emptySet. A single match is
Collections.singleton.
packages - packages discovered for one simple name; null is emptyprecedence - package prefixes in the order they must be tried; null yields an empty set