cdm.margin.schedule.functions.StandardizedScheduleFXNDFNotional Maven / Gradle / Ivy
package cdm.margin.schedule.functions;
import cdm.base.math.NonNegativeQuantitySchedule;
import cdm.base.math.NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder;
import cdm.base.math.metafields.ReferenceWithMetaNonNegativeQuantitySchedule;
import cdm.product.common.settlement.ResolvablePriceQuantity;
import cdm.product.template.SettlementPayout;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.ModelObjectValidator;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import java.util.Optional;
import javax.inject.Inject;
@ImplementedBy(StandardizedScheduleFXNDFNotional.StandardizedScheduleFXNDFNotionalDefault.class)
public abstract class StandardizedScheduleFXNDFNotional implements RosettaFunction {
@Inject protected ModelObjectValidator objectValidator;
/**
* @param settlementPayout
* @return quantity
*/
public NonNegativeQuantitySchedule evaluate(SettlementPayout settlementPayout) {
NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder quantityBuilder = doEvaluate(settlementPayout);
final NonNegativeQuantitySchedule quantity;
if (quantityBuilder == null) {
quantity = null;
} else {
quantity = quantityBuilder.build();
objectValidator.validate(NonNegativeQuantitySchedule.class, quantity);
}
return quantity;
}
protected abstract NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder doEvaluate(SettlementPayout settlementPayout);
public static class StandardizedScheduleFXNDFNotionalDefault extends StandardizedScheduleFXNDFNotional {
@Override
protected NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder doEvaluate(SettlementPayout settlementPayout) {
NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder quantity = NonNegativeQuantitySchedule.builder();
return assignOutput(quantity, settlementPayout);
}
protected NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder assignOutput(NonNegativeQuantitySchedule.NonNegativeQuantityScheduleBuilder quantity, SettlementPayout settlementPayout) {
final ReferenceWithMetaNonNegativeQuantitySchedule referenceWithMetaNonNegativeQuantitySchedule = MapperS.of(settlementPayout).map("getPriceQuantity", _settlementPayout -> _settlementPayout.getPriceQuantity()).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).get();
if (referenceWithMetaNonNegativeQuantitySchedule == null) {
quantity = null;
} else {
quantity = toBuilder(referenceWithMetaNonNegativeQuantitySchedule.getValue());
}
return Optional.ofNullable(quantity)
.map(o -> o.prune())
.orElse(null);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy