(
Class<R> returnType,
ClockUnit unit,
PlainTime context,
long amount
)
| 2209 | } |
| 2210 | |
| 2211 | private static <R> R doAdd( |
| 2212 | Class<R> returnType, |
| 2213 | ClockUnit unit, |
| 2214 | PlainTime context, |
| 2215 | long amount |
| 2216 | ) { |
| 2217 | |
| 2218 | long hours; |
| 2219 | long minutes; |
| 2220 | long seconds; |
| 2221 | long nanos; |
| 2222 | |
| 2223 | int minute = context.minute; |
| 2224 | int second = context.second; |
| 2225 | int fraction = context.nano; |
| 2226 | |
| 2227 | switch (unit) { |
| 2228 | case HOURS: |
| 2229 | hours = MathUtils.safeAdd(context.hour, amount); |
| 2230 | break; |
| 2231 | case MINUTES: |
| 2232 | minutes = MathUtils.safeAdd(context.minute, amount); |
| 2233 | hours = |
| 2234 | MathUtils.safeAdd( |
| 2235 | context.hour, |
| 2236 | MathUtils.floorDivide(minutes, 60)); |
| 2237 | minute = MathUtils.floorModulo(minutes, 60); |
| 2238 | break; |
| 2239 | case SECONDS: |
| 2240 | seconds = MathUtils.safeAdd(context.second, amount); |
| 2241 | minutes = |
| 2242 | MathUtils.safeAdd( |
| 2243 | context.minute, |
| 2244 | MathUtils.floorDivide(seconds, 60)); |
| 2245 | hours = |
| 2246 | MathUtils.safeAdd( |
| 2247 | context.hour, |
| 2248 | MathUtils.floorDivide(minutes, 60)); |
| 2249 | minute = MathUtils.floorModulo(minutes, 60); |
| 2250 | second = MathUtils.floorModulo(seconds, 60); |
| 2251 | break; |
| 2252 | case MILLIS: |
| 2253 | return doAdd( |
| 2254 | returnType, |
| 2255 | ClockUnit.NANOS, |
| 2256 | context, |
| 2257 | MathUtils.safeMultiply(amount, MIO)); |
| 2258 | case MICROS: |
| 2259 | return doAdd( |
| 2260 | returnType, |
| 2261 | ClockUnit.NANOS, |
| 2262 | context, |
| 2263 | MathUtils.safeMultiply(amount, KILO)); |
| 2264 | case NANOS: |
| 2265 | nanos = |
| 2266 | MathUtils.safeAdd(context.nano, amount); |
| 2267 | seconds = |
| 2268 | MathUtils.safeAdd( |
no test coverage detected