All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdm.product.common.functions.InterestRatePayoutCurrency Maven / Gradle / Ivy

There is a newer version: 6.0.0-dev.89
Show newest version
package cdm.product.common.functions;

import cdm.base.math.NonNegativeQuantitySchedule;
import cdm.base.math.UnitType;
import cdm.base.math.metafields.ReferenceWithMetaNonNegativeQuantitySchedule;
import cdm.product.asset.InterestRatePayout;
import cdm.product.common.schedule.FxLinkedNotionalSchedule;
import cdm.product.common.settlement.QuantityMultiplier;
import cdm.product.common.settlement.ResolvablePriceQuantity;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperC;
import com.rosetta.model.metafields.FieldWithMetaString;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@ImplementedBy(InterestRatePayoutCurrency.InterestRatePayoutCurrencyDefault.class)
public abstract class InterestRatePayoutCurrency implements RosettaFunction {

	/**
	* @param interestRatePayouts List of interest rate payouts.
	* @return currency List of currencies collected from the payouts.
	*/
	public List evaluate(List interestRatePayouts) {
		List currency = doEvaluate(interestRatePayouts);
		
		return currency;
	}

	protected abstract List doEvaluate(List interestRatePayouts);

	public static class InterestRatePayoutCurrencyDefault extends InterestRatePayoutCurrency {
		@Override
		protected List doEvaluate(List interestRatePayouts) {
			if (interestRatePayouts == null) {
				interestRatePayouts = Collections.emptyList();
			}
			List currency = new ArrayList<>();
			return assignOutput(currency, interestRatePayouts);
		}
		
		protected List assignOutput(List currency, List interestRatePayouts) {
			currency.addAll(MapperC.of(interestRatePayouts).map("getPriceQuantity", interestRatePayout -> interestRatePayout.getPriceQuantity()).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("Type coercion", referenceWithMetaNonNegativeQuantitySchedule -> referenceWithMetaNonNegativeQuantitySchedule.getValue()).map("getUnit", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getUnit()).map("getCurrency", unitType -> unitType.getCurrency()).map("Type coercion", fieldWithMetaString -> fieldWithMetaString.getValue()).getMulti());
			
			currency.addAll(MapperC.of(interestRatePayouts).map("getPriceQuantity", interestRatePayout -> interestRatePayout.getPriceQuantity()).map("getQuantityMultiplier", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantityMultiplier()).map("getFxLinkedNotionalSchedule", quantityMultiplier -> quantityMultiplier.getFxLinkedNotionalSchedule()).map("getVaryingNotionalCurrency", fxLinkedNotionalSchedule -> fxLinkedNotionalSchedule.getVaryingNotionalCurrency()).map("Type coercion", fieldWithMetaString -> fieldWithMetaString.getValue()).getMulti());
			
			return currency;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy