| 4280 | } |
| 4281 | |
| 4282 | private void update( |
| 4283 | long amount, |
| 4284 | long factor |
| 4285 | ) { |
| 4286 | |
| 4287 | if (amount >= 0) { |
| 4288 | IsoUnit unit = NANOS; |
| 4289 | |
| 4290 | for (int i = this.items.size() - 1; i >= 0; i--) { |
| 4291 | Item<IsoUnit> item = this.items.get(i); |
| 4292 | if (item.getUnit().equals(NANOS)) { |
| 4293 | this.items.set( |
| 4294 | i, |
| 4295 | Item.of( |
| 4296 | MathUtils.safeAdd( |
| 4297 | MathUtils.safeMultiply(amount, factor), |
| 4298 | item.getAmount() |
| 4299 | ), |
| 4300 | unit |
| 4301 | ) |
| 4302 | ); |
| 4303 | return; |
| 4304 | } |
| 4305 | } |
| 4306 | |
| 4307 | if (amount != 0) { |
| 4308 | this.items.add( |
| 4309 | Item.of( |
| 4310 | MathUtils.safeMultiply(amount, factor), |
| 4311 | unit |
| 4312 | ) |
| 4313 | ); |
| 4314 | } |
| 4315 | |
| 4316 | } else { |
| 4317 | throw new IllegalArgumentException( |
| 4318 | "Illegal negative amount: " + amount); |
| 4319 | } |
| 4320 | |
| 4321 | } |
| 4322 | |
| 4323 | private void millisCalled() { |
| 4324 | |