-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaFX.java
More file actions
76 lines (69 loc) · 2.17 KB
/
JavaFX.java
File metadata and controls
76 lines (69 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2024 Christian Stein
* Licensed under the Universal Permissive License v 1.0 -> https://opensource.org/license/upl
*/
package run.info.bach;
import java.util.Set;
import run.bach.ModuleLocator;
import run.bach.info.MavenCoordinate;
import run.bach.info.OperatingSystem;
/**
* JavaFX is a client application platform.
*
* @see <a href="https://openjfx.io">Homepage</a>
*/
public record JavaFX(String version, String classifier) implements ModuleLocator {
public static JavaFX version(String version) {
return version(version, OperatingSystem.CURRENT);
}
public static JavaFX version(String version, OperatingSystem os) {
return new JavaFX(version, computeClassifier(os));
}
/**
* @see <a href="https://repo.maven.apache.org/maven2/org/openjfx/">org.openjfx</a>
*/
@Override
public Set<String> names() {
return Set.of(
"javafx.base",
"javafx.controls",
"javafx.fxml",
"javafx.graphics",
"javafx.media",
"javafx.swing",
"javafx.web");
}
@Override
public Location locate(String module) {
if (!names().contains(module)) return Location.unknown(module);
var group = "org.openjfx";
var artifact = module.replace('.', '-');
var coordinate = MavenCoordinate.ofCentral(group, artifact, version, classifier);
return Location.of(module, coordinate.toUri().toString());
}
public static String computeClassifier(OperatingSystem os) {
var name = os.name();
var architecture = os.architecture();
@SuppressWarnings("SwitchStatementWithTooFewBranches")
var classifier =
switch (name) {
case ANY -> throw new UnsupportedOperationException();
case LINUX ->
switch (architecture) {
case ARM_64 -> "linux-aarch64";
default -> "linux";
};
case MAC ->
switch (architecture) {
case ARM_64 -> "mac-aarch64";
default -> "mac";
};
case WINDOWS ->
switch (architecture) {
case X86_32 -> "win-x86";
default -> "win";
};
};
return classifier;
}
}