Skip to content

Commit

Permalink
Merge pull request #23 from Fox2Code/module_desc_builder_stubs
Browse files Browse the repository at this point in the history
Add some ModuleDescriptor Builder stubs
  • Loading branch information
wagyourtail authored Nov 29, 2024
2 parents f50cabe + c1902d3 commit 29645ce
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 29645ce

Please sign in to comment.