MCPcopy
hub / github.com/oshi/oshi / MacBaseboard

Class MacBaseboard

oshi-core/src/main/java/oshi/hardware/platform/mac/MacBaseboard.java:44–109  ·  view source on GitHub ↗

Baseboard data obtained from ioreg

Source from the content-addressed store, hash-verified

42 * Baseboard data obtained from ioreg
43 */
44@Immutable
45final class MacBaseboard extends AbstractBaseboard {
46
47 private final Supplier<Quartet<String, String, String, String>> manufModelVersSerial = memoize(
48 MacBaseboard::queryPlatform);
49
50 @Override
51 public String getManufacturer() {
52 return manufModelVersSerial.get().getA();
53 }
54
55 @Override
56 public String getModel() {
57 return manufModelVersSerial.get().getB();
58 }
59
60 @Override
61 public String getVersion() {
62 return manufModelVersSerial.get().getC();
63 }
64
65 @Override
66 public String getSerialNumber() {
67 return manufModelVersSerial.get().getD();
68 }
69
70 private static Quartet<String, String, String, String> queryPlatform() {
71 String manufacturer = null;
72 String model = null;
73 String version = null;
74 String serialNumber = null;
75
76 IORegistryEntry platformExpert = IOKitUtil.getMatchingService("IOPlatformExpertDevice");
77 if (platformExpert != null) {
78 byte[] data = platformExpert.getByteArrayProperty("manufacturer");
79 if (data != null) {
80 manufacturer = Native.toString(data, StandardCharsets.UTF_8);
81 }
82 data = platformExpert.getByteArrayProperty("board-id");
83 if (data != null) {
84 model = Native.toString(data, StandardCharsets.UTF_8);
85 }
86 if (Util.isBlank(model)) {
87 data = platformExpert.getByteArrayProperty("model-number");
88 if (data != null) {
89 model = Native.toString(data, StandardCharsets.UTF_8);
90 }
91 }
92 data = platformExpert.getByteArrayProperty("version");
93 if (data != null) {
94 version = Native.toString(data, StandardCharsets.UTF_8);
95 }
96 data = platformExpert.getByteArrayProperty("mlb-serial-number");
97 if (data != null) {
98 serialNumber = Native.toString(data, StandardCharsets.UTF_8);
99 }
100 if (Util.isBlank(serialNumber)) {
101 serialNumber = platformExpert.getStringProperty("IOPlatformSerialNumber");

Callers

nothing calls this directly

Calls 1

memoizeMethod · 0.80

Tested by

no test coverage detected