1 package org.djunits.unit.si;
2
3 import java.io.Serializable;
4
5 import org.djutils.exceptions.Throw;
6
7
8
9
10
11
12
13
14
15 public class SIPrefix implements Serializable
16 {
17
18 private static final long serialVersionUID = 20190821L;
19
20
21 private final String defaultTextualPrefix;
22
23
24 private final String defaultDisplayPrefix;
25
26
27 private final String prefixName;
28
29
30 private final double factor;
31
32
33
34
35
36
37
38
39 public SIPrefix(final String defaultTextualPrefix, final String prefixName, final double factor,
40 final String defaultDisplayPrefix)
41 {
42 Throw.whenNull(defaultTextualPrefix, "SIPrefix.defaultTextualPrefix cannot be null");
43 Throw.whenNull(prefixName, "SIPrefix.prefixName cannot be null");
44 Throw.whenNull(defaultDisplayPrefix, "SIPrefix.defaultDisplayPrefix cannot be null");
45 Throw.when(factor == 0, SIRuntimeException.class, "SIPrefix.factor cannot be 0");
46 this.defaultTextualPrefix = defaultTextualPrefix;
47 this.prefixName = prefixName;
48 this.factor = factor;
49 this.defaultDisplayPrefix = defaultDisplayPrefix;
50 }
51
52
53
54
55
56
57
58 public SIPrefix(final String defaultTextualPrefix, final String prefixName, final double factor)
59 {
60 this(defaultTextualPrefix, prefixName, factor, defaultTextualPrefix);
61 }
62
63
64
65
66
67 public String getDefaultTextualPrefix()
68 {
69 return this.defaultTextualPrefix;
70 }
71
72
73
74
75
76 public String getPrefixName()
77 {
78 return this.prefixName;
79 }
80
81
82
83
84
85 public double getFactor()
86 {
87 return this.factor;
88 }
89
90
91
92
93
94 public String getDefaultDisplayPrefix()
95 {
96 return this.defaultDisplayPrefix;
97 }
98
99 @Override
100 public String toString()
101 {
102 return "SIPrefix [defaultTextualPrefix=" + this.defaultTextualPrefix + ", defaultDisplayPrefix="
103 + this.defaultDisplayPrefix + ", prefixName=" + this.prefixName + ", factor=" + this.factor + "]";
104 }
105
106 }