| 51 | * @author Meno Hochschild |
| 52 | */ |
| 53 | public final class TimeAxis<U, T extends TimePoint<U, T>> |
| 54 | extends Chronology<T> |
| 55 | implements TimeLine<T> { |
| 56 | |
| 57 | //~ Instanzvariablen -------------------------------------------------- |
| 58 | |
| 59 | private final Class<U> unitType; |
| 60 | private final Map<U, UnitRule<T>> unitRules; |
| 61 | private final Map<U, Double> unitLengths; |
| 62 | private final Map<U, Set<U>> convertibleUnits; |
| 63 | private final Map<ChronoElement<?>, U> baseUnits; |
| 64 | private final T min; |
| 65 | private final T max; |
| 66 | private final CalendarSystem<T> calendarSystem; |
| 67 | private final ChronoElement<T> self; |
| 68 | private final TimeLine<T> timeline; |
| 69 | |
| 70 | //~ Konstruktoren ----------------------------------------------------- |
| 71 | |
| 72 | private TimeAxis( |
| 73 | Class<T> chronoType, |
| 74 | Class<U> unitType, |
| 75 | ChronoMerger<T> merger, |
| 76 | Map<ChronoElement<?>, ElementRule<T, ?>> ruleMap, |
| 77 | Map<U, UnitRule<T>> unitRules, |
| 78 | final Map<U, Double> unitLengths, |
| 79 | Map<U, Set<U>> convertibleUnits, |
| 80 | List<ChronoExtension> extensions, |
| 81 | Map<ChronoElement<?>, U> baseUnits, |
| 82 | T min, |
| 83 | T max, |
| 84 | CalendarSystem<T> calendarSystem, // optional |
| 85 | TimeLine<T> timeline, // optional |
| 86 | boolean useEnumUnits |
| 87 | ) { |
| 88 | super(chronoType, merger, ruleMap, extensions); |
| 89 | |
| 90 | Map<U, UnitRule<T>> uRules = unitRules; |
| 91 | |
| 92 | if (useEnumUnits) { |
| 93 | uRules = new IdentityHashMap<>(unitRules.size()); |
| 94 | uRules.putAll(unitRules); |
| 95 | } |
| 96 | |
| 97 | this.unitType = unitType; |
| 98 | this.unitRules = uRules; |
| 99 | this.unitLengths = Collections.unmodifiableMap(unitLengths); |
| 100 | this.convertibleUnits = Collections.unmodifiableMap(convertibleUnits); |
| 101 | this.baseUnits = Collections.unmodifiableMap(baseUnits); |
| 102 | this.min = min; |
| 103 | this.max = max; |
| 104 | this.calendarSystem = calendarSystem; |
| 105 | this.self = new SelfElement<>(chronoType, min, max); |
| 106 | |
| 107 | if (timeline == null) { |
| 108 | List<U> registeredUnits = new ArrayList<>(unitRules.keySet()); |
| 109 | registeredUnits.sort(Comparator.comparingDouble(unit -> getLength(unitLengths, unit))); |
| 110 | U step = registeredUnits.get(0); |
nothing calls this directly
no outgoing calls
no test coverage detected