use of org.killbill.billing.jaxrs.json.TierPriceJson in project killbill by killbill.
the class SubscriptionResourceHelpers method buildUsagePrices.
private static void buildUsagePrices(final Currency currency, final PhasePriceJson input, final Collection<UsagePriceOverride> usagePrices) {
for (final UsagePriceJson usageOverrideJson : input.getUsagePrices()) {
final List<TierPriceOverride> tierPriceOverrides = new LinkedList<TierPriceOverride>();
for (final TierPriceJson tierPriceJson : usageOverrideJson.getTierPrices()) {
final List<TieredBlockPriceOverride> blockPriceOverrides = new LinkedList<TieredBlockPriceOverride>();
for (final BlockPriceJson block : tierPriceJson.getBlockPrices()) {
blockPriceOverrides.add(new TieredBlockPriceOverride() {
@Override
public String getUnitName() {
return block.getUnitName();
}
@Override
public Double getSize() {
return block.getSize();
}
@Override
public BigDecimal getPrice() {
return block.getPrice();
}
@Override
public Currency getCurrency() {
return currency;
}
@Override
public Double getMax() {
return block.getMax();
}
});
}
tierPriceOverrides.add(new TierPriceOverride() {
@Override
public List<TieredBlockPriceOverride> getTieredBlockPriceOverrides() {
return blockPriceOverrides;
}
});
}
usagePrices.add(new UsagePriceOverride() {
@Override
public String getName() {
return usageOverrideJson.getUsageName();
}
@Override
public UsageType getUsageType() {
return usageOverrideJson.getUsageType();
}
@Override
public List<TierPriceOverride> getTierPriceOverrides() {
return tierPriceOverrides;
}
});
}
}
Aggregations