1
2
3
4
5 package oshi.hardware.platform.linux;
6
7 import static oshi.util.Memoizer.memoize;
8
9 import java.util.function.Supplier;
10
11 import oshi.annotation.concurrent.Immutable;
12 import oshi.driver.linux.Sysfs;
13 import oshi.driver.linux.proc.CpuInfo;
14 import oshi.hardware.common.AbstractBaseboard;
15 import oshi.util.Constants;
16 import oshi.util.tuples.Quartet;
17
18
19
20
21 @Immutable
22 final class LinuxBaseboard extends AbstractBaseboard {
23
24 private final Supplier<String> manufacturer = memoize(this::queryManufacturer);
25 private final Supplier<String> model = memoize(this::queryModel);
26 private final Supplier<String> version = memoize(this::queryVersion);
27 private final Supplier<String> serialNumber = memoize(this::querySerialNumber);
28 private final Supplier<Quartet<String, String, String, String>> manufacturerModelVersionSerial = memoize(
29 CpuInfo::queryBoardInfo);
30
31 @Override
32 public String getManufacturer() {
33 return manufacturer.get();
34 }
35
36 @Override
37 public String getModel() {
38 return model.get();
39 }
40
41 @Override
42 public String getVersion() {
43 return version.get();
44 }
45
46 @Override
47 public String getSerialNumber() {
48 return serialNumber.get();
49 }
50
51 private String queryManufacturer() {
52 String result = null;
53 if ((result = Sysfs.queryBoardVendor()) == null
54 && (result = manufacturerModelVersionSerial.get().getA()) == null) {
55 return Constants.UNKNOWN;
56 }
57 return result;
58 }
59
60 private String queryModel() {
61 String result = null;
62 if ((result = Sysfs.queryBoardModel()) == null
63 && (result = manufacturerModelVersionSerial.get().getB()) == null) {
64 return Constants.UNKNOWN;
65 }
66 return result;
67 }
68
69 private String queryVersion() {
70 String result = null;
71 if ((result = Sysfs.queryBoardVersion()) == null
72 && (result = manufacturerModelVersionSerial.get().getC()) == null) {
73 return Constants.UNKNOWN;
74 }
75 return result;
76 }
77
78 private String querySerialNumber() {
79 String result = null;
80 if ((result = Sysfs.queryBoardSerial()) == null
81 && (result = manufacturerModelVersionSerial.get().getD()) == null) {
82 return Constants.UNKNOWN;
83 }
84 return result;
85 }
86 }