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

Method update

base/src/main/java/net/time4j/Duration.java:4282–4321  ·  view source on GitHub ↗
(
            long amount,
            long factor
        )

Source from the content-addressed store, hash-verified

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

Callers 3

millisMethod · 0.95
microsMethod · 0.95
nanosMethod · 0.95

Calls 10

ofMethod · 0.95
safeAddMethod · 0.95
safeMultiplyMethod · 0.95
getMethod · 0.65
sizeMethod · 0.45
equalsMethod · 0.45
getUnitMethod · 0.45
setMethod · 0.45
getAmountMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected