< prev index next >

src/java.base/share/classes/java/lang/module/ModuleDescriptor.java

Print this page




1314      * <p> Returns the module name. </p>
1315      *
1316      * @return The module name
1317      */
1318     public String name() {
1319         return name;
1320     }
1321 
1322     /**
1323      * <p> Returns the set of module modifiers. </p>
1324      *
1325      * @return A possibly-empty unmodifiable set of modifiers
1326      */
1327     public Set<Modifier> modifiers() {
1328         return modifiers;
1329     }
1330 
1331     /**
1332      * <p> Returns {@code true} if this is an open module. </p>
1333      *
1334      * <p> This method is equivalent to testing if the set of {@link #modifiers
1335      * modifiers} contains the {@link Modifier#OPEN OPEN} modifier. </p>
1336      *
1337      * @return  {@code true} if this is an open module
1338      */
1339     public boolean isOpen() {
1340         return open;
1341     }
1342 
1343     /**
1344      * <p> Returns {@code true} if this is an automatic module. </p>
1345      *
1346      * <p> This method is equivalent to testing if the set of {@link #modifiers
1347      * modifiers} contains the {@link Modifier#OPEN AUTOMATIC} modifier. </p>
1348      *
1349      * @return  {@code true} if this is an automatic module
1350      */
1351     public boolean isAutomatic() {
1352         return automatic;
1353     }
1354 
1355     /**
1356      * <p> Returns the set of {@code Requires} objects representing the module
1357      * dependences. </p>
1358      *
1359      * <p> The set includes a dependency on "{@code java.base}" when this
1360      * module is not named "{@code java.base}". If this module is an automatic
1361      * module then it does not have a dependency on any module other than
1362      * "{@code java.base}". </p>
1363      *
1364      * @return  A possibly-empty unmodifiable set of {@link Requires} objects
1365      */
1366     public Set<Requires> requires() {


1672          *         If the module name is {@code null}, is not a legal module
1673          *         name, or is equal to the module name that this builder
1674          *         was initialized to build
1675          * @throws IllegalStateException
1676          *         If the dependence on the module has already been declared
1677          *         or this builder is for an automatic module
1678          */
1679         public Builder requires(String mn) {
1680             return requires(EnumSet.noneOf(Requires.Modifier.class), mn);
1681         }
1682 
1683         /**
1684          * Adds an exported package.
1685          *
1686          * @param  e
1687          *         The export
1688          *
1689          * @return This builder
1690          *
1691          * @throws IllegalStateException
1692          *         If the {@link Exports#source package} is already declared as
1693          *         exported or this builder is for an automatic module
1694          */
1695         public Builder exports(Exports e) {
1696             if (automatic) {
1697                 throw new IllegalStateException("Automatic modules cannot declare"
1698                                                  + " exported packages");
1699             }
1700             String source = e.source();
1701             if (exports.containsKey(source)) {
1702                 throw new IllegalStateException("Exported package " + source
1703                                                  + " already declared");
1704             }
1705             exports.put(source, e);
1706             packages.add(source);
1707             return this;
1708         }
1709 
1710         /**
1711          * Adds an exported package with the given (and possibly empty) set of
1712          * modifiers. The package is exported to a set of target modules.




1314      * <p> Returns the module name. </p>
1315      *
1316      * @return The module name
1317      */
1318     public String name() {
1319         return name;
1320     }
1321 
1322     /**
1323      * <p> Returns the set of module modifiers. </p>
1324      *
1325      * @return A possibly-empty unmodifiable set of modifiers
1326      */
1327     public Set<Modifier> modifiers() {
1328         return modifiers;
1329     }
1330 
1331     /**
1332      * <p> Returns {@code true} if this is an open module. </p>
1333      *
1334      * <p> This method is equivalent to testing if the set of {@link #modifiers()
1335      * modifiers} contains the {@link Modifier#OPEN OPEN} modifier. </p>
1336      *
1337      * @return  {@code true} if this is an open module
1338      */
1339     public boolean isOpen() {
1340         return open;
1341     }
1342 
1343     /**
1344      * <p> Returns {@code true} if this is an automatic module. </p>
1345      *
1346      * <p> This method is equivalent to testing if the set of {@link #modifiers()
1347      * modifiers} contains the {@link Modifier#OPEN AUTOMATIC} modifier. </p>
1348      *
1349      * @return  {@code true} if this is an automatic module
1350      */
1351     public boolean isAutomatic() {
1352         return automatic;
1353     }
1354 
1355     /**
1356      * <p> Returns the set of {@code Requires} objects representing the module
1357      * dependences. </p>
1358      *
1359      * <p> The set includes a dependency on "{@code java.base}" when this
1360      * module is not named "{@code java.base}". If this module is an automatic
1361      * module then it does not have a dependency on any module other than
1362      * "{@code java.base}". </p>
1363      *
1364      * @return  A possibly-empty unmodifiable set of {@link Requires} objects
1365      */
1366     public Set<Requires> requires() {


1672          *         If the module name is {@code null}, is not a legal module
1673          *         name, or is equal to the module name that this builder
1674          *         was initialized to build
1675          * @throws IllegalStateException
1676          *         If the dependence on the module has already been declared
1677          *         or this builder is for an automatic module
1678          */
1679         public Builder requires(String mn) {
1680             return requires(EnumSet.noneOf(Requires.Modifier.class), mn);
1681         }
1682 
1683         /**
1684          * Adds an exported package.
1685          *
1686          * @param  e
1687          *         The export
1688          *
1689          * @return This builder
1690          *
1691          * @throws IllegalStateException
1692          *         If the {@link Exports#source() package} is already declared as
1693          *         exported or this builder is for an automatic module
1694          */
1695         public Builder exports(Exports e) {
1696             if (automatic) {
1697                 throw new IllegalStateException("Automatic modules cannot declare"
1698                                                  + " exported packages");
1699             }
1700             String source = e.source();
1701             if (exports.containsKey(source)) {
1702                 throw new IllegalStateException("Exported package " + source
1703                                                  + " already declared");
1704             }
1705             exports.put(source, e);
1706             packages.add(source);
1707             return this;
1708         }
1709 
1710         /**
1711          * Adds an exported package with the given (and possibly empty) set of
1712          * modifiers. The package is exported to a set of target modules.


< prev index next >