1725 * If the package name is {@code null} or is not a legal
1726 * package name, the set of target modules is empty, or the set
1727 * of target modules contains a name that is not a legal module
1728 * name
1729 * @throws IllegalStateException
1730 * If the package is already declared as exported
1731 * or this builder is for an automatic module
1732 */
1733 public Builder exports(Set<Exports.Modifier> ms,
1734 String pn,
1735 Set<String> targets)
1736 {
1737 Exports e = new Exports(ms, pn, targets);
1738
1739 // check targets
1740 targets = e.targets();
1741 if (targets.isEmpty())
1742 throw new IllegalArgumentException("Empty target set");
1743 if (strict) {
1744 requirePackageName(e.source());
1745 targets.stream().forEach(Checks::requireModuleName);
1746 }
1747 return exports(e);
1748 }
1749
1750 /**
1751 * Adds an exported package with the given (and possibly empty) set of
1752 * modifiers. The package is exported to all modules.
1753 *
1754 * @param ms
1755 * The set of modifiers
1756 * @param pn
1757 * The package name
1758 *
1759 * @return This builder
1760 *
1761 * @throws IllegalArgumentException
1762 * If the package name is {@code null} or is not a legal
1763 * package name
1764 * @throws IllegalStateException
1765 * If the package is already declared as exported
1861 * If the package name is {@code null} or is not a legal
1862 * package name, the set of target modules is empty, or the set
1863 * of target modules contains a name that is not a legal module
1864 * name
1865 * @throws IllegalStateException
1866 * If the package is already declared as open, or this is a
1867 * builder for an open module or automatic module
1868 */
1869 public Builder opens(Set<Opens.Modifier> ms,
1870 String pn,
1871 Set<String> targets)
1872 {
1873 Opens opens = new Opens(ms, pn, targets);
1874
1875 // check targets
1876 targets = opens.targets();
1877 if (targets.isEmpty())
1878 throw new IllegalArgumentException("Empty target set");
1879 if (strict) {
1880 requirePackageName(opens.source());
1881 targets.stream().forEach(Checks::requireModuleName);
1882 }
1883 return opens(opens);
1884 }
1885
1886 /**
1887 * Adds an open package with the given (and possibly empty) set of
1888 * modifiers. The package is open to all modules.
1889 *
1890 * @param ms
1891 * The set of modifiers
1892 * @param pn
1893 * The package name
1894 *
1895 * @return This builder
1896 *
1897 * @throws IllegalArgumentException
1898 * If the package name is {@code null} or is not a legal
1899 * package name
1900 * @throws IllegalStateException
1901 * If the package is already declared as open, or this is a
|
1725 * If the package name is {@code null} or is not a legal
1726 * package name, the set of target modules is empty, or the set
1727 * of target modules contains a name that is not a legal module
1728 * name
1729 * @throws IllegalStateException
1730 * If the package is already declared as exported
1731 * or this builder is for an automatic module
1732 */
1733 public Builder exports(Set<Exports.Modifier> ms,
1734 String pn,
1735 Set<String> targets)
1736 {
1737 Exports e = new Exports(ms, pn, targets);
1738
1739 // check targets
1740 targets = e.targets();
1741 if (targets.isEmpty())
1742 throw new IllegalArgumentException("Empty target set");
1743 if (strict) {
1744 requirePackageName(e.source());
1745 targets.forEach(Checks::requireModuleName);
1746 }
1747 return exports(e);
1748 }
1749
1750 /**
1751 * Adds an exported package with the given (and possibly empty) set of
1752 * modifiers. The package is exported to all modules.
1753 *
1754 * @param ms
1755 * The set of modifiers
1756 * @param pn
1757 * The package name
1758 *
1759 * @return This builder
1760 *
1761 * @throws IllegalArgumentException
1762 * If the package name is {@code null} or is not a legal
1763 * package name
1764 * @throws IllegalStateException
1765 * If the package is already declared as exported
1861 * If the package name is {@code null} or is not a legal
1862 * package name, the set of target modules is empty, or the set
1863 * of target modules contains a name that is not a legal module
1864 * name
1865 * @throws IllegalStateException
1866 * If the package is already declared as open, or this is a
1867 * builder for an open module or automatic module
1868 */
1869 public Builder opens(Set<Opens.Modifier> ms,
1870 String pn,
1871 Set<String> targets)
1872 {
1873 Opens opens = new Opens(ms, pn, targets);
1874
1875 // check targets
1876 targets = opens.targets();
1877 if (targets.isEmpty())
1878 throw new IllegalArgumentException("Empty target set");
1879 if (strict) {
1880 requirePackageName(opens.source());
1881 targets.forEach(Checks::requireModuleName);
1882 }
1883 return opens(opens);
1884 }
1885
1886 /**
1887 * Adds an open package with the given (and possibly empty) set of
1888 * modifiers. The package is open to all modules.
1889 *
1890 * @param ms
1891 * The set of modifiers
1892 * @param pn
1893 * The package name
1894 *
1895 * @return This builder
1896 *
1897 * @throws IllegalArgumentException
1898 * If the package name is {@code null} or is not a legal
1899 * package name
1900 * @throws IllegalStateException
1901 * If the package is already declared as open, or this is a
|