blob: 50463553f8ea3843744f8d30d56c0c40ab3fd019 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.pricing;
import java.math.BigDecimal;
import java.util.List;
import static java.math.BigDecimal.ZERO;
public record PriceInformation(BigDecimal listPriceWithSupport, BigDecimal volumeDiscount,
BigDecimal committedAmountDiscount, BigDecimal enclaveDiscount, BigDecimal totalAmount) {
public static PriceInformation empty() { return new PriceInformation(ZERO, ZERO, ZERO, ZERO, ZERO); }
public static PriceInformation sum(List<PriceInformation> priceInformationList) {
var result = PriceInformation.empty();
for (var prices : priceInformationList)
result = result.add(prices);
return result;
}
public PriceInformation add(PriceInformation priceInformation) {
return new PriceInformation(this.listPriceWithSupport().add(priceInformation.listPriceWithSupport()),
this.volumeDiscount().add(priceInformation.volumeDiscount()),
this.committedAmountDiscount().add(priceInformation.committedAmountDiscount()),
this.enclaveDiscount().add(priceInformation.enclaveDiscount()),
this.totalAmount().add(priceInformation.totalAmount()));
}
}
|