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

cdm.margin.schedule.functions.StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQ Maven / Gradle / Ivy

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

import cdm.base.math.Measure;
import cdm.base.math.NonNegativeQuantitySchedule;
import cdm.base.math.UnitType;
import cdm.base.math.metafields.ReferenceWithMetaNonNegativeQuantitySchedule;
import cdm.product.common.settlement.ResolvablePriceQuantity;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import com.rosetta.model.metafields.FieldWithMetaString;

import static com.rosetta.model.lib.expression.ExpressionOperators.*;

@ImplementedBy(StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQ.StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQDefault.class)
public abstract class StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQ implements RosettaFunction {

	/**
	* @param priceQuantity 
	* @return notionalCurrency 
	*/
	public String evaluate(ResolvablePriceQuantity priceQuantity) {
		String notionalCurrency = doEvaluate(priceQuantity);
		
		return notionalCurrency;
	}

	protected abstract String doEvaluate(ResolvablePriceQuantity priceQuantity);

	public static class StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQDefault extends StandardizedScheduleMonetaryNotionalCurrencyFromResolvablePQ {
		@Override
		protected String doEvaluate(ResolvablePriceQuantity priceQuantity) {
			String notionalCurrency = null;
			return assignOutput(notionalCurrency, priceQuantity);
		}
		
		protected String assignOutput(String notionalCurrency, ResolvablePriceQuantity priceQuantity) {
			if (exists(MapperS.of(priceQuantity).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue())).and(exists(MapperS.of(priceQuantity).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue()).map("getUnit", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getUnit()).map("getCurrency", unitType -> unitType.getCurrency()).map("getValue", _f->_f.getValue()))).getOrDefault(false)) {
				if (exists(MapperS.of(priceQuantity).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue()).map("getMultiplier", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getMultiplier())).getOrDefault(false)) {
					notionalCurrency = MapperS.of(priceQuantity).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue()).map("getMultiplier", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getMultiplier()).map("getUnit", measure -> measure.getUnit()).map("getCurrency", unitType -> unitType.getCurrency()).map("getValue", _f->_f.getValue()).get();
				} else {
					notionalCurrency = MapperS.of(priceQuantity).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue()).map("getUnit", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getUnit()).map("getCurrency", unitType -> unitType.getCurrency()).map("getValue", _f->_f.getValue()).get();
				}
			} else {
				notionalCurrency = null;
			}
			
			return notionalCurrency;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy