1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.jute.system;
17
18 import static com.google.common.base.StandardSystemProperty.JAVA_VM_NAME;
19 import static com.google.common.base.StandardSystemProperty.JAVA_VM_VENDOR;
20 import static com.google.common.base.StandardSystemProperty.JAVA_VM_VERSION;
21 import static org.kuali.common.jute.reflect.Reflection.checkNoNulls;
22 import static org.kuali.common.jute.system.Specification.buildVirtualMachineSpecification;
23
24 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
25
26 @JsonDeserialize(builder = VirtualMachine.Builder.class)
27 public final class VirtualMachine {
28
29 private final String name;
30 private final String version;
31 private final String vendor;
32 private final Specification specification;
33
34 private VirtualMachine(Builder builder) {
35 this.name = builder.name;
36 this.vendor = builder.vendor;
37 this.version = builder.version;
38 this.specification = builder.specification;
39 }
40
41 public static VirtualMachine build() {
42 Builder builder = builder();
43 builder.withName(JAVA_VM_NAME.value());
44 builder.withVendor(JAVA_VM_VENDOR.value());
45 builder.withVersion(JAVA_VM_VERSION.value());
46 builder.withSpecification(buildVirtualMachineSpecification());
47 return builder.build();
48 }
49
50 public static Builder builder() {
51 return new Builder();
52 }
53
54 public static class Builder implements org.apache.commons.lang3.builder.Builder<VirtualMachine> {
55
56 private String name;
57 private String version;
58 private String vendor;
59 private Specification specification;
60
61 public Builder withName(String name) {
62 this.name = name;
63 return this;
64 }
65
66 public Builder withVendor(String vendor) {
67 this.vendor = vendor;
68 return this;
69 }
70
71 public Builder withVersion(String version) {
72 this.version = version;
73 return this;
74 }
75
76 public Builder withSpecification(Specification specification) {
77 this.specification = specification;
78 return this;
79 }
80
81 @Override
82 public VirtualMachine build() {
83 return checkNoNulls(new VirtualMachine(this));
84 }
85 }
86
87 public String getName() {
88 return name;
89 }
90
91 public String getVendor() {
92 return vendor;
93 }
94
95 public String getVersion() {
96 return version;
97 }
98
99 public Specification getSpecification() {
100 return specification;
101 }
102
103 }