1 package org.djunits.unit.system;
2
3 import java.util.Objects;
4
5 import org.djutils.exceptions.Throw;
6
7
8
9
10
11
12
13
14 public class UnitSystem
15 {
16
17 public static final UnitSystem CGS = new UnitSystem("CGS", "centimeter-gram-second system");
18
19
20 public static final UnitSystem CGS_ESU = new UnitSystem("CGS-ESU", "centimeter-gram-second system, electrostatic units");
21
22
23 public static final UnitSystem CGS_EMU = new UnitSystem("CGS-EMU", "centimeter-gram-second system, electromagnetic units");
24
25
26 public static final UnitSystem IMPERIAL = new UnitSystem("Imperial", "Imperial system");
27
28
29 public static final UnitSystem MTS = new UnitSystem("MTS", "meter-tonne-second system");
30
31
32 public static final UnitSystem OTHER = new UnitSystem("Other", "other system");
33
34
35 public static final UnitSystem SI_ACCEPTED = new UnitSystem("SI-accepted", "International System of Units (Accepted Unit)");
36
37
38 public static final UnitSystem SI_BASE = new UnitSystem("SI", "International System of Units (Base Unit)");
39
40
41 public static final UnitSystem SI_DERIVED = new UnitSystem("SI-derived", "International System of Units (Derived Unit)");
42
43
44 public static final UnitSystem US_CUSTOMARY = new UnitSystem("US-customary", "US customary system");
45
46
47 public static final UnitSystem AU = new UnitSystem("AU", "Atomic Unit system");
48
49
50 private final String id;
51
52
53 private final String name;
54
55
56
57
58
59
60 public UnitSystem(final String id, final String name)
61 {
62 Throw.whenNull(id, "id");
63 Throw.whenNull(name, "name");
64 Throw.when(id.strip().length() == 0, IllegalArgumentException.class, "id cannot be empty");
65 Throw.when(name.strip().length() == 0, IllegalArgumentException.class, "name cannot be empty");
66 this.id = id.strip();
67 this.name = name.strip();
68 }
69
70
71
72
73
74 public final String getName()
75 {
76 return this.name;
77 }
78
79
80
81
82
83 public final String getId()
84 {
85 return this.id;
86 }
87
88 @Override
89 public int hashCode()
90 {
91 return Objects.hash(this.id, this.name);
92 }
93
94 @Override
95 @SuppressWarnings("checkstyle:needbraces")
96 public boolean equals(final Object obj)
97 {
98 if (this == obj)
99 return true;
100 if (obj == null)
101 return false;
102 if (getClass() != obj.getClass())
103 return false;
104 UnitSystem other = (UnitSystem) obj;
105 return Objects.equals(this.id, other.id) && Objects.equals(this.name, other.name);
106 }
107
108 @Override
109 public String toString()
110 {
111 return "UnitSystem [id=" + this.id + ", name=" + this.name + "]";
112 }
113
114 }