Module java.base

Class ModuleDescriptor.Builder

java.lang.Object
java.lang.module.ModuleDescriptor.Builder
Enclosing class:
ModuleDescriptor

public static final class ModuleDescriptor.Builder extends Object
A builder for building ModuleDescriptor objects.

ModuleDescriptor defines the newModule, newOpenModule, and newAutomaticModule methods to create builders for building normal, open, and automatic modules.

The set of packages in the module are accumulated by the Builder as the exports, opens, packages, provides, and mainClass methods are invoked.

The module names, package names, and class names that are parameters specified to the builder methods are the module names, package names, and qualified names of classes (in named packages) as defined in the The Java Language Specification.

Example usage:

    ModuleDescriptor descriptor = ModuleDescriptor.newModule("stats.core")
        .requires("java.base")
        .exports("org.acme.stats.core.clustering")
        .exports("org.acme.stats.core.regression")
        .packages(Set.of("org.acme.stats.core.internal"))
        .build();
API Note:
A Builder checks the components and invariants as components are added to the builder. The rationale for this is to detect errors as early as possible and not defer all validation to the build method.
Since:
9