MCPcopy Create free account
hub / github.com/MenoData/Time4J / ClockNormalizer

Class ClockNormalizer

base/src/main/java/net/time4j/ClockNormalizer.java:40–202  ·  view source on GitHub ↗

Hilfsobjekt zur Normalisierung einer Uhrzeit-bezogenen Dauer. @author Meno Hochschild @since 3.0

Source from the content-addressed store, hash-verified

38 * @since 3.0
39 */
40final class ClockNormalizer
41 implements Normalizer<ClockUnit> {
42
43 //~ Statische Felder/Initialisierungen --------------------------------
44
45 private static final int ONLY_MODE = 0;
46 private static final int TRUNCATE_MODE = 1;
47 private static final int ROUNDING_MODE = 2;
48
49 private static final Map<ClockUnit, ClockNormalizer> MAP_ONLY;
50 private static final Map<ClockUnit, ClockNormalizer> MAP_TRUNC;
51 private static final Map<ClockUnit, ClockNormalizer> MAP_ROUND;
52
53 static {
54 MAP_ONLY = fill(ONLY_MODE);
55 MAP_TRUNC = fill(TRUNCATE_MODE);
56 MAP_ROUND = fill(ROUNDING_MODE);
57 }
58
59 //~ Instanzvariablen --------------------------------------------------
60
61 private final ClockUnit unit;
62 private final int mode;
63
64 //~ Konstruktoren -----------------------------------------------------
65
66 private ClockNormalizer(
67 ClockUnit unit,
68 int mode
69 ) {
70 super();
71
72 this.unit = unit;
73 this.mode = mode;
74
75 }
76
77 //~ Methoden ----------------------------------------------------------
78
79 /**
80 * <p>Liefert einen passenden Normalisierer. </p>
81 *
82 * @param unit clock unit
83 * @return unique normalizer instance
84 */
85 static ClockNormalizer ofOnlyMode(ClockUnit unit) {
86
87 ClockNormalizer ret = MAP_ONLY.get(unit);
88
89 if (ret == null) {
90 throw new IllegalArgumentException(unit.name());
91 }
92
93 return ret;
94
95 }
96
97 /**

Callers

nothing calls this directly

Calls 1

fillMethod · 0.95

Tested by

no test coverage detected