1 package org.djunits.unit;
2
3 import org.djunits.unit.si.SIDimensions;
4 import org.djunits.unit.util.UnitException;
5
6
7
8
9
10
11
12
13
14 public class SIUnit extends Unit<SIUnit>
15 {
16
17 private static final long serialVersionUID = 20190829L;
18
19 static
20 {
21
22 try
23 {
24 Class.forName("org.djunits.unit.util.UNITS");
25 }
26 catch (ClassNotFoundException exception)
27 {
28 exception.printStackTrace();
29 }
30 }
31
32
33
34
35
36
37
38 public static SIUnit of(final String siString) throws UnitException
39 {
40 return Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(siString));
41 }
42
43
44
45
46
47
48
49 public static SIUnit of(final SIDimensions siDimensions) throws UnitException
50 {
51 return Unit.lookupOrCreateUnitWithSIDimensions(siDimensions);
52 }
53
54
55 @Override
56 public String toString()
57 {
58 return getQuantity().getSiDimensions().toString(true, false);
59 }
60
61
62 @Override
63 @SuppressWarnings("checkstyle:designforextension")
64 public int hashCode()
65 {
66 return getQuantity().getSiDimensions().hashCode();
67 }
68
69
70 @Override
71 @SuppressWarnings({"checkstyle:designforextension", "checkstyle:needbraces"})
72 public boolean equals(final Object obj)
73 {
74 if (this == obj)
75 return true;
76 if (obj == null)
77 return false;
78 if (getClass() != obj.getClass())
79 return false;
80 SIUnit other = (SIUnit) obj;
81 if (!getQuantity().getSiDimensions().equals(other.getQuantity().getSiDimensions()))
82 return false;
83 return true;
84 }
85
86 }