(
long amount,
U unit
)
| 1535 | * @see #plus(long, IsoUnit) plus(long, U) |
| 1536 | */ |
| 1537 | public Duration<U> with( |
| 1538 | long amount, |
| 1539 | U unit |
| 1540 | ) { |
| 1541 | |
| 1542 | long absAmount = |
| 1543 | ((amount < 0) ? MathUtils.safeNegate(amount) : amount); |
| 1544 | Item<U> item = replaceFraction(absAmount, unit); |
| 1545 | |
| 1546 | if (item != null) { |
| 1547 | absAmount = item.getAmount(); |
| 1548 | unit = item.getUnit(); |
| 1549 | } |
| 1550 | |
| 1551 | long oldAmount = this.getPartialAmount(unit); |
| 1552 | |
| 1553 | return this.plus( |
| 1554 | MathUtils.safeSubtract( |
| 1555 | MathUtils.safeMultiply( |
| 1556 | absAmount, |
| 1557 | (amount < 0) ? -1 : 1 |
| 1558 | ), |
| 1559 | MathUtils.safeMultiply( |
| 1560 | oldAmount, |
| 1561 | this.isNegative() ? -1 : 1 |
| 1562 | ) |
| 1563 | ), |
| 1564 | unit |
| 1565 | ); |
| 1566 | |
| 1567 | } |
| 1568 | |
| 1569 | /** |
| 1570 | * <p>Gets the absolute always non-negative copy of this duration. </p> |
nothing calls this directly
no test coverage detected