public static final class ModuleDescriptor.Builder extends Object
ModuleDescriptor
objects.
ModuleDescriptor
defines the module
, openModule
, and automaticModule
methods to create builders for building different kinds of modules.
Example usage:
ModuleDescriptor descriptor = ModuleDescriptor.module("m1")
.exports("p")
.requires("m2")
.build();
Modifier and Type | Method | Description |
---|---|---|
ModuleDescriptor |
build() |
Builds and returns a
ModuleDescriptor from its components. |
ModuleDescriptor.Builder |
contains(String pn) |
Adds a package to the module.
|
ModuleDescriptor.Builder |
contains(Set<String> pns) |
Adds a (possible empty) set of packages to the module
|
ModuleDescriptor.Builder |
exports(ModuleDescriptor.Exports e) |
Adds an export.
|
ModuleDescriptor.Builder |
exports(String pn) |
Adds an unqualified export.
|
ModuleDescriptor.Builder |
exports(String pn,
Set<String> targets) |
Adds an export to export a package to a set of target modules.
|
ModuleDescriptor.Builder |
exports(Set<ModuleDescriptor.Exports.Modifier> ms,
String pn) |
Adds an unqualified export with the given (and possibly empty) set
of modifiers.
|
ModuleDescriptor.Builder |
exports(Set<ModuleDescriptor.Exports.Modifier> ms,
String pn,
Set<String> targets) |
Adds an export, with the given (and possibly empty) set of modifiers,
to export a package to a set of target modules.
|
ModuleDescriptor.Builder |
mainClass(String mc) |
Sets the module main class.
|
ModuleDescriptor.Builder |
opens(ModuleDescriptor.Opens obj) |
Adds an opens directive.
|
ModuleDescriptor.Builder |
opens(String pn) |
Adds an opens directive to open a package.
|
ModuleDescriptor.Builder |
opens(String pn,
Set<String> targets) |
Adds an opens directive to open a package to a set of target
modules.
|
ModuleDescriptor.Builder |
opens(Set<ModuleDescriptor.Opens.Modifier> ms,
String pn) |
Adds an opens directive to open a package with the given (and
possibly empty) set of modifiers.
|
ModuleDescriptor.Builder |
opens(Set<ModuleDescriptor.Opens.Modifier> ms,
String pn,
Set<String> targets) |
Adds an opens directive, with the given (and possibly empty)
set of modifiers, to open a package to a set of target modules.
|
ModuleDescriptor.Builder |
osArch(String arch) |
Sets the operating system architecture.
|
ModuleDescriptor.Builder |
osName(String name) |
Sets the operating system name.
|
ModuleDescriptor.Builder |
osVersion(String version) |
Sets the operating system version.
|
ModuleDescriptor.Builder |
provides(ModuleDescriptor.Provides p) |
Provides a service with one or more implementations.
|
ModuleDescriptor.Builder |
provides(String service,
String provider) |
Provides an implementation of a service.
|
ModuleDescriptor.Builder |
provides(String service,
List<String> providers) |
Provides implementations of a service.
|
ModuleDescriptor.Builder |
requires(ModuleDescriptor.Requires req) |
Adds a dependence on a module.
|
ModuleDescriptor.Builder |
requires(String mn) |
Adds a dependence on a module with an empty set of modifiers.
|
ModuleDescriptor.Builder |
requires(Set<ModuleDescriptor.Requires.Modifier> ms,
String mn) |
Adds a dependence on a module with the given (and possibly empty)
set of modifiers.
|
ModuleDescriptor.Builder |
requires(Set<ModuleDescriptor.Requires.Modifier> ms,
String mn,
ModuleDescriptor.Version compiledVersion) |
Adds a dependence on a module with the given (and possibly empty)
set of modifiers.
|
ModuleDescriptor.Builder |
uses(String service) |
Adds a service dependence.
|
ModuleDescriptor.Builder |
version(ModuleDescriptor.Version v) |
Sets the module version.
|
ModuleDescriptor.Builder |
version(String v) |
Sets the module version.
|
public ModuleDescriptor.Builder requires(ModuleDescriptor.Requires req)
req
- The dependenceIllegalArgumentException
- If the dependence is on the module that this builder was
initialized to buildIllegalStateException
- If the dependence on the module has already been declaredpublic ModuleDescriptor.Builder requires(Set<ModuleDescriptor.Requires.Modifier> ms, String mn, ModuleDescriptor.Version compiledVersion)
ms
- The set of modifiersmn
- The module namecompiledVersion
- The version of the module recorded at compile-timeIllegalArgumentException
- If the module name is null
, is not a legal Java
identifier, or is equal to the module name that this builder
was initialized to buildIllegalStateException
- If the dependence on the module has already been declaredpublic ModuleDescriptor.Builder requires(Set<ModuleDescriptor.Requires.Modifier> ms, String mn)
ms
- The set of modifiersmn
- The module nameIllegalArgumentException
- If the module name is null
, is not a legal Java
identifier, or is equal to the module name that this builder
was initialized to buildIllegalStateException
- If the dependence on the module has already been declaredpublic ModuleDescriptor.Builder requires(String mn)
mn
- The module nameIllegalArgumentException
- If the module name is null
, is not a legal Java
identifier, or is equal to the module name that this builder
was initialized to buildIllegalStateException
- If the dependence on the module has already been declaredpublic ModuleDescriptor.Builder exports(ModuleDescriptor.Exports e)
e
- The exportIllegalStateException
- If the package is already declared as a package with the
contains
method or the package is already
declared as exportedpublic ModuleDescriptor.Builder exports(Set<ModuleDescriptor.Exports.Modifier> ms, String pn, Set<String> targets)
ms
- The set of modifierspn
- The package nametargets
- The set of target modules namesIllegalArgumentException
- If the package name or any of the target modules is
null
or is not a legal Java identifier, or the set of
targets is emptyIllegalStateException
- If the package is already declared as a package with the
contains
method or the package is already
declared as exportedpublic ModuleDescriptor.Builder exports(Set<ModuleDescriptor.Exports.Modifier> ms, String pn)
ms
- The set of modifierspn
- The package nameIllegalArgumentException
- If the package name is null
or is not a legal Java
identifierIllegalStateException
- If the package is already declared as a package with the
contains
method or the package is already
declared as exportedpublic ModuleDescriptor.Builder exports(String pn, Set<String> targets)
pn
- The package nametargets
- The set of target modules namesIllegalArgumentException
- If the package name or any of the target modules is
null
or is not a legal Java identifier, or the set of
targets is emptyIllegalStateException
- If the package is already declared as a package with the
contains
method or the package is already
declared as exportedpublic ModuleDescriptor.Builder exports(String pn)
pn
- The package nameIllegalArgumentException
- If the package name is null
or is not a legal Java
identifierIllegalStateException
- If the package is already declared as a package with the
contains
method or the package is already
declared as exportedpublic ModuleDescriptor.Builder opens(ModuleDescriptor.Opens obj)
obj
- The Opens
objectIllegalStateException
- If the package is already declared as a package with the
contains
method, the package is already
declared as open, or this is a builder for an open modulepublic ModuleDescriptor.Builder opens(Set<ModuleDescriptor.Opens.Modifier> ms, String pn, Set<String> targets)
ms
- The set of modifierspn
- The package nametargets
- The set of target modules namesIllegalArgumentException
- If the package name or any of the target modules is
null
or is not a legal Java identifier, or the set of
targets is emptyIllegalStateException
- If the package is already declared as a package with the
contains
method, the package is already
declared as open, or this is a builder for an open modulepublic ModuleDescriptor.Builder opens(Set<ModuleDescriptor.Opens.Modifier> ms, String pn)
ms
- The set of modifierspn
- The package nameIllegalArgumentException
- If the package name is null
or is not a legal Java
identifierIllegalStateException
- If the package is already declared as a package with the
contains
method, the package is already
declared as open, or this is a builder for an open modulepublic ModuleDescriptor.Builder opens(String pn, Set<String> targets)
pn
- The package nametargets
- The set of target modules namesIllegalArgumentException
- If the package name or any of the target modules is
null
or is not a legal Java identifier, or the set of
targets is emptyIllegalStateException
- If the package is already declared as a package with the
contains
method, the package is already
declared as open, or this is a builder for an open modulepublic ModuleDescriptor.Builder opens(String pn)
pn
- The package nameIllegalArgumentException
- If the package name is null
or is not a legal Java
identifierIllegalStateException
- If the package is already declared as a package with the
contains
method, the package is already
declared as open, or this is a builder for an open modulepublic ModuleDescriptor.Builder uses(String service)
service
- The service typeIllegalArgumentException
- If the service type is null
or is not a legal Java
identifierIllegalStateException
- If a dependency on the service type has already been declaredpublic ModuleDescriptor.Builder provides(ModuleDescriptor.Provides p)
p
- The providesIllegalStateException
- If the providers for the service type have already been
declaredpublic ModuleDescriptor.Builder provides(String service, List<String> providers)
service
- The service typeproviders
- The list of provider or provider factory class namesIllegalArgumentException
- If the service type or any of the provider class names is
null
or is not a legal Java identifier, or the list
of provider class names is emptyIllegalStateException
- If the providers for the service type have already been
declaredpublic ModuleDescriptor.Builder provides(String service, String provider)
service
- The service typeprovider
- The provider or provider factory class nameIllegalArgumentException
- If the service type or the provider class name is
null
or is not a legal Java identifierIllegalStateException
- If the providers for the service type have already been
declaredpublic ModuleDescriptor.Builder contains(Set<String> pns)
pns
- The set of package namesIllegalArgumentException
- If any of the package names is null
or is not a
legal Java identifierIllegalStateException
- If any of packages are already declared as packages in
the module. This includes packages that are already
declared as exported or open packages.public ModuleDescriptor.Builder contains(String pn)
pn
- The package nameIllegalArgumentException
- If the package name is null
, or is not a legal Java
identifierIllegalStateException
- If the package is already declared as a package in the
module. This includes the package already declared as an
exported or open package.public ModuleDescriptor.Builder version(ModuleDescriptor.Version v)
v
- The versionpublic ModuleDescriptor.Builder version(String v)
v
- The version string to parseIllegalArgumentException
- If v
is null or cannot be parsed as a version stringModuleDescriptor.Version.parse(String)
public ModuleDescriptor.Builder mainClass(String mc)
mc
- The module main classIllegalArgumentException
- If mainClass
is null or is not a legal Java identifierpublic ModuleDescriptor.Builder osName(String name)
name
- The operating system nameIllegalArgumentException
- If name
is null or the empty Stringpublic ModuleDescriptor.Builder osArch(String arch)
arch
- The operating system architectureIllegalArgumentException
- If name
is null or the empty Stringpublic ModuleDescriptor.Builder osVersion(String version)
version
- The operating system versionIllegalArgumentException
- If name
is null or the empty Stringpublic ModuleDescriptor build()
ModuleDescriptor
from its components. Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-Ubuntu+0-9b151-2