Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/main/java/io/smallrye/modules/desc/PackageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ public static PackageInfo merge(PackageInfo a, PackageInfo b) {
* @param newAccess the minimum access level (must not be {@code null})
*/
public PackageInfo withAccessAtLeast(PackageAccess newAccess) {
return of(
PackageAccess.max(packageAccess(), newAccess),
exportTargets,
openTargets);
return packageAccess().isAtLeast(newAccess) ? this
: of(
newAccess,
exportTargets,
openTargets);
}

/**
Expand All @@ -115,10 +116,24 @@ public PackageInfo withAccessAtLeast(PackageAccess newAccess) {
* @param exportTargets additional export targets (must not be {@code null})
*/
public PackageInfo withExportTargets(final Set<String> exportTargets) {
return of(
packageAccess(),
Util.merge(exportTargets(), exportTargets),
openTargets());
return exportTargets().containsAll(exportTargets) ? this
: of(
packageAccess(),
Util.merge(exportTargets(), exportTargets),
openTargets());
}

/**
* {@return a package info with the given open targets merged with existing targets (not {@code null})}
*
* @param openTargets additional open targets (must not be {@code null})
*/
public PackageInfo withOpenTargets(final Set<String> openTargets) {
return exportTargets().containsAll(openTargets) ? this
: of(
packageAccess(),
exportTargets(),
Util.merge(openTargets(), openTargets));
}

/**
Expand Down
Loading