936 /**
937 * Adds a dependence on a module with the given (and possibly empty)
938 * set of modifiers.
939 *
940 * @param mods
941 * The set of modifiers
942 * @param mn
943 * The module name
944 *
945 * @return This builder
946 *
947 * @throws IllegalArgumentException
948 * If the module name is {@code null}, is not a legal Java
949 * identifier, or is equal to the module name that this builder
950 * was initialized to build
951 * @throws IllegalStateException
952 * If the dependence on the module has already been declared
953 */
954 public Builder requires(Set<Requires.Modifier> mods, String mn) {
955 if (name.equals(mn))
956 throw new IllegalArgumentException("Dependence on self");
957 if (requires.containsKey(mn))
958 throw new IllegalStateException("Dependence upon " + mn
959 + " already declared");
960 requires.put(mn, new Requires(mods, mn)); // checks mn
961 return this;
962 }
963
964 /**
965 * Adds a dependence on a module with an empty set of modifiers.
966 *
967 * @param mn
968 * The module name
969 *
970 * @return This builder
971 *
972 * @throws IllegalArgumentException
973 * If the module name is {@code null}, is not a legal Java
974 * identifier, or is equal to the module name that this builder
975 * was initialized to build
976 * @throws IllegalStateException
1256 return this;
1257 }
1258
1259 /**
1260 * Sets the module version.
1261 *
1262 * @param v
1263 * The version string to parse
1264 *
1265 * @return This builder
1266 *
1267 * @throws IllegalArgumentException
1268 * If {@code v} is null or cannot be parsed as a version string
1269 * @throws IllegalStateException
1270 * If the module version is already set
1271 *
1272 * @see Version#parse(String)
1273 */
1274 public Builder version(String v) {
1275 if (version != null)
1276 throw new IllegalStateException("module version already set");
1277 version = Version.parse(v);
1278 return this;
1279 }
1280
1281 /**
1282 * Sets the module main class.
1283 *
1284 * @param mc
1285 * The module main class
1286 *
1287 * @return This builder
1288 *
1289 * @throws IllegalArgumentException
1290 * If {@code mainClass} is null or is not a legal Java identifier
1291 * @throws IllegalStateException
1292 * If the module main class is already set
1293 */
1294 public Builder mainClass(String mc) {
1295 if (mainClass != null)
1296 throw new IllegalStateException("main class already set");
1297 mainClass = requireJavaIdentifier("main class name", mc);
1298 return this;
1299 }
1300
1301 /**
1302 * Sets the operating system name.
1303 *
1304 * @param name
1305 * The operating system name
1306 *
1307 * @return This builder
1308 *
1309 * @throws IllegalArgumentException
1310 * If {@code name} is null or the empty String
1311 * @throws IllegalStateException
1312 * If the operating system name is already set
1313 */
1314 public Builder osName(String name) {
1315 if (osName != null)
1316 throw new IllegalStateException("OS name already set");
1317 if (name == null || name.isEmpty())
1318 throw new IllegalArgumentException("OS name is null or empty");
1319 osName = name;
1320 return this;
1321 }
1322
1323 /**
1324 * Sets the operating system architecture.
1325 *
1326 * @param arch
1327 * The operating system architecture
1328 *
1329 * @return This builder
1330 *
1331 * @throws IllegalArgumentException
1332 * If {@code name} is null or the empty String
1333 * @throws IllegalStateException
1334 * If the operating system architecture is already set
1335 */
1336 public Builder osArch(String arch) {
1337 if (osArch != null)
1338 throw new IllegalStateException("OS arch already set");
1339 if (arch == null || arch.isEmpty())
1340 throw new IllegalArgumentException("OS arch is null or empty");
1341 osArch = arch;
1342 return this;
1343 }
1344
1345 /**
1346 * Sets the operating system version.
1347 *
1348 * @param version
1349 * The operating system version
1350 *
1351 * @return This builder
1352 *
1353 * @throws IllegalArgumentException
1354 * If {@code name} is null or the empty String
1355 * @throws IllegalStateException
1356 * If the operating system version is already set
1357 */
1358 public Builder osVersion(String version) {
1359 if (osVersion != null)
1360 throw new IllegalStateException("OS version already set");
1361 if (version == null || version.isEmpty())
1362 throw new IllegalArgumentException("OS version is null or empty");
1363 osVersion = version;
1364 return this;
1365 }
1366
1367 /* package */ Builder hashes(DependencyHashes hashes) {
1368 this.hashes = hashes;
1369 return this;
1370 }
1371
1372
1373 /* package */ Builder synthetic(boolean v) {
1374 this.synthetic = v;
1375 return this;
1376 }
1377
1378 /**
1379 * Builds and returns a {@code ModuleDescriptor} from its components.
1380 *
|
936 /**
937 * Adds a dependence on a module with the given (and possibly empty)
938 * set of modifiers.
939 *
940 * @param mods
941 * The set of modifiers
942 * @param mn
943 * The module name
944 *
945 * @return This builder
946 *
947 * @throws IllegalArgumentException
948 * If the module name is {@code null}, is not a legal Java
949 * identifier, or is equal to the module name that this builder
950 * was initialized to build
951 * @throws IllegalStateException
952 * If the dependence on the module has already been declared
953 */
954 public Builder requires(Set<Requires.Modifier> mods, String mn) {
955 if (name.equals(mn))
956 throw new IllegalArgumentException("Dependence on self: " + mn);
957 if (requires.containsKey(mn))
958 throw new IllegalStateException("Dependence upon " + mn
959 + " already declared");
960 requires.put(mn, new Requires(mods, mn)); // checks mn
961 return this;
962 }
963
964 /**
965 * Adds a dependence on a module with an empty set of modifiers.
966 *
967 * @param mn
968 * The module name
969 *
970 * @return This builder
971 *
972 * @throws IllegalArgumentException
973 * If the module name is {@code null}, is not a legal Java
974 * identifier, or is equal to the module name that this builder
975 * was initialized to build
976 * @throws IllegalStateException
1256 return this;
1257 }
1258
1259 /**
1260 * Sets the module version.
1261 *
1262 * @param v
1263 * The version string to parse
1264 *
1265 * @return This builder
1266 *
1267 * @throws IllegalArgumentException
1268 * If {@code v} is null or cannot be parsed as a version string
1269 * @throws IllegalStateException
1270 * If the module version is already set
1271 *
1272 * @see Version#parse(String)
1273 */
1274 public Builder version(String v) {
1275 if (version != null)
1276 throw new IllegalStateException(
1277 "module version already set: " + version);
1278 version = Version.parse(v);
1279 return this;
1280 }
1281
1282 /**
1283 * Sets the module main class.
1284 *
1285 * @param mc
1286 * The module main class
1287 *
1288 * @return This builder
1289 *
1290 * @throws IllegalArgumentException
1291 * If {@code mainClass} is null or is not a legal Java identifier
1292 * @throws IllegalStateException
1293 * If the module main class is already set
1294 */
1295 public Builder mainClass(String mc) {
1296 if (mainClass != null)
1297 throw new IllegalStateException(
1298 "main class already set: " + mainClass);
1299 mainClass = requireJavaIdentifier("main class name", mc);
1300 return this;
1301 }
1302
1303 /**
1304 * Sets the operating system name.
1305 *
1306 * @param name
1307 * The operating system name
1308 *
1309 * @return This builder
1310 *
1311 * @throws IllegalArgumentException
1312 * If {@code name} is null or the empty String
1313 * @throws IllegalStateException
1314 * If the operating system name is already set
1315 */
1316 public Builder osName(String name) {
1317 if (osName != null)
1318 throw new IllegalStateException(
1319 "OS name already set: " + osName);
1320 if (name == null || name.isEmpty())
1321 throw new IllegalArgumentException("OS name is null or empty");
1322 osName = name;
1323 return this;
1324 }
1325
1326 /**
1327 * Sets the operating system architecture.
1328 *
1329 * @param arch
1330 * The operating system architecture
1331 *
1332 * @return This builder
1333 *
1334 * @throws IllegalArgumentException
1335 * If {@code name} is null or the empty String
1336 * @throws IllegalStateException
1337 * If the operating system architecture is already set
1338 */
1339 public Builder osArch(String arch) {
1340 if (osArch != null)
1341 throw new IllegalStateException(
1342 "OS arch already set: " + osArch);
1343 if (arch == null || arch.isEmpty())
1344 throw new IllegalArgumentException("OS arch is null or empty");
1345 osArch = arch;
1346 return this;
1347 }
1348
1349 /**
1350 * Sets the operating system version.
1351 *
1352 * @param version
1353 * The operating system version
1354 *
1355 * @return This builder
1356 *
1357 * @throws IllegalArgumentException
1358 * If {@code name} is null or the empty String
1359 * @throws IllegalStateException
1360 * If the operating system version is already set
1361 */
1362 public Builder osVersion(String version) {
1363 if (osVersion != null)
1364 throw new IllegalStateException(
1365 "OS version already set: " + osVersion);
1366 if (version == null || version.isEmpty())
1367 throw new IllegalArgumentException("OS version is null or empty");
1368 osVersion = version;
1369 return this;
1370 }
1371
1372 /* package */ Builder hashes(DependencyHashes hashes) {
1373 this.hashes = hashes;
1374 return this;
1375 }
1376
1377
1378 /* package */ Builder synthetic(boolean v) {
1379 this.synthetic = v;
1380 return this;
1381 }
1382
1383 /**
1384 * Builds and returns a {@code ModuleDescriptor} from its components.
1385 *
|