cdm.observable.asset.functions.InterestRateObservableCondition Maven / Gradle / Ivy
package cdm.observable.asset.functions;
import cdm.base.math.ArithmeticOperationEnum;
import cdm.observable.asset.Index;
import cdm.observable.asset.Observable;
import cdm.observable.asset.PriceQuantity;
import cdm.observable.asset.PriceSchedule;
import cdm.observable.asset.PriceTypeEnum;
import cdm.observable.asset.metafields.FieldWithMetaFloatingRateIndex;
import cdm.observable.asset.metafields.FieldWithMetaObservable;
import cdm.observable.asset.metafields.FieldWithMetaPriceSchedule;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.CardinalityOperator;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(InterestRateObservableCondition.InterestRateObservableConditionDefault.class)
public abstract class InterestRateObservableCondition implements RosettaFunction {
/**
* @param pq
* @return valid
*/
public Boolean evaluate(PriceQuantity pq) {
Boolean valid = doEvaluate(pq);
return valid;
}
protected abstract Boolean doEvaluate(PriceQuantity pq);
public static class InterestRateObservableConditionDefault extends InterestRateObservableCondition {
@Override
protected Boolean doEvaluate(PriceQuantity pq) {
Boolean valid = null;
return assignOutput(valid, pq);
}
protected Boolean assignOutput(Boolean valid, PriceQuantity pq) {
if (exists(MapperS.of(pq).map("getObservable", priceQuantity -> priceQuantity.getObservable()).map("Type coercion", fieldWithMetaObservable -> fieldWithMetaObservable == null ? null : fieldWithMetaObservable.getValue()).map("getIndex", observable -> observable.getIndex()).map("getFloatingRateIndex", index -> index.getFloatingRateIndex())).and(exists(MapperS.of(pq).mapC("getPrice", priceQuantity -> priceQuantity.getPrice()))).getOrDefault(false)) {
valid = areEqual(MapperS.of(pq).mapC("getPrice", priceQuantity -> priceQuantity.getPrice())
.mapItem(item -> areEqual(item.map("Type coercion", fieldWithMetaPriceSchedule0 -> fieldWithMetaPriceSchedule0 == null ? null : fieldWithMetaPriceSchedule0.getValue()).map("getPriceType", priceSchedule -> priceSchedule.getPriceType()), MapperS.of(PriceTypeEnum.INTEREST_RATE), CardinalityOperator.All).and(exists(item.map("Type coercion", fieldWithMetaPriceSchedule1 -> fieldWithMetaPriceSchedule1 == null ? null : fieldWithMetaPriceSchedule1.getValue()).map("getArithmeticOperator", priceSchedule -> priceSchedule.getArithmeticOperator()))).asMapper()), MapperS.of(true), CardinalityOperator.All).get();
} else {
valid = null;
}
return valid;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy