Skip to content

Commit

Permalink
Add some ModuleDescriptor Builder stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox2Code committed Nov 26, 2024
1 parent cb724f4 commit c1902d3
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,26 @@ public String toString() {
return sb.toString();
}

public static Builder newModule(String name, Set<Modifier> ms) {
Set<Modifier> mods = new HashSet<>(ms);
if (mods.contains(Modifier.AUTOMATIC) && mods.size() > 1) {
throw new IllegalArgumentException("AUTOMATIC cannot be used with other modifiers");
}
return new Builder(name, true, mods);
}

public static Builder newModule(String name) {
return new Builder(name, true, Collections.emptySet());
}

public static Builder newOpenModule(String name) {
return new Builder(name, true, Collections.singleton(Modifier.OPEN));
}

public static Builder newAutomaticModule(String name) {
return new Builder(name, true, Collections.singleton(Modifier.AUTOMATIC));
}

@Adapter("java/lang/module/ModuleDescriptor$Modifier")
public enum Modifier {
OPEN, AUTOMATIC, SYNTHETIC, MANDATED
Expand Down

0 comments on commit c1902d3

Please sign in to comment.