cdm.event.common.functions.Qualify_Repurchase Maven / Gradle / Ivy
package cdm.event.common.functions;
import cdm.event.common.BusinessEvent;
import cdm.event.common.CollateralPortfolio;
import cdm.event.common.CollateralPosition;
import cdm.event.common.EventIntentEnum;
import cdm.event.common.Instruction;
import cdm.event.common.PrimitiveInstruction;
import cdm.event.common.State;
import cdm.event.common.Trade;
import cdm.event.common.TradeState;
import cdm.event.common.metafields.ReferenceWithMetaCollateralPortfolio;
import cdm.event.common.metafields.ReferenceWithMetaTradeState;
import cdm.legaldocumentation.common.ClosedState;
import cdm.legaldocumentation.common.ClosedStateEnum;
import cdm.product.collateral.Collateral;
import cdm.product.template.AssetPayout;
import cdm.product.template.ContractualProduct;
import cdm.product.template.EconomicTerms;
import cdm.product.template.Payout;
import cdm.product.template.Product;
import cdm.product.template.TradableProduct;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.CardinalityOperator;
import com.rosetta.model.lib.functions.IQualifyFunctionExtension;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import java.util.Arrays;
import javax.inject.Inject;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(Qualify_Repurchase.Qualify_RepurchaseDefault.class)
public abstract class Qualify_Repurchase implements RosettaFunction,IQualifyFunctionExtension {
// RosettaFunction dependencies
//
@Inject protected QuantityDecreasedToZero quantityDecreasedToZero;
/**
* @param businessEvent
* @return is_event
*/
@Override
public Boolean evaluate(BusinessEvent businessEvent) {
Boolean is_event = doEvaluate(businessEvent);
return is_event;
}
protected abstract Boolean doEvaluate(BusinessEvent businessEvent);
public static class Qualify_RepurchaseDefault extends Qualify_Repurchase {
@Override
protected Boolean doEvaluate(BusinessEvent businessEvent) {
Boolean is_event = null;
return assignOutput(is_event, businessEvent);
}
protected Boolean assignOutput(Boolean is_event, BusinessEvent businessEvent) {
is_event = areEqual(MapperS.of(businessEvent).map("getIntent", _businessEvent -> _businessEvent.getIntent()), MapperS.of(EventIntentEnum.REPURCHASE), CardinalityOperator.All).and(exists(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).map("getTrade", tradeState -> tradeState.getTrade()).map("getTradableProduct", trade -> trade.getTradableProduct()).map("getProduct", tradableProduct -> tradableProduct.getProduct()).map("getContractualProduct", product -> product.getContractualProduct()).map("getEconomicTerms", contractualProduct -> contractualProduct.getEconomicTerms()).map("getCollateral", economicTerms -> economicTerms.getCollateral()).mapC("getCollateralPortfolio", collateral -> collateral.getCollateralPortfolio()).map("getValue", _f->_f.getValue()).mapC("getCollateralPosition", collateralPortfolio -> collateralPortfolio.getCollateralPosition()).map("getProduct", collateralPosition -> collateralPosition.getProduct()).map("getContractualProduct", product -> product.getContractualProduct()).map("getEconomicTerms", contractualProduct -> contractualProduct.getEconomicTerms()).map("getPayout", economicTerms -> economicTerms.getPayout()).mapC("getAssetPayout", payout -> payout.getAssetPayout()))).and(areEqual(MapperS.of(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).resultCount()), MapperS.of(1), CardinalityOperator.All).and(onlyExists(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).map("getPrimitiveInstruction", instruction -> instruction.getPrimitiveInstruction()), Arrays.asList("contractFormation", "execution", "exercise", "partyChange", "quantityChange", "reset", "split", "termsChange", "transfer", "indexTransition", "stockSplit", "observation", "valuation"), Arrays.asList("quantityChange", "transfer")))).and(areEqual(MapperS.of(quantityDecreasedToZero.evaluate(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).map("getBefore", instruction -> instruction.getBefore()).map("getValue", _f->_f.getValue()).getMulti(), MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).getMulti())), MapperS.of(true), CardinalityOperator.All)).and(areEqual(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).map("getState", tradeState -> tradeState.getState()).map("getClosedState", state -> state.getClosedState()).map("getState", closedState -> closedState.getState()), MapperS.of(ClosedStateEnum.TERMINATED), CardinalityOperator.All)).get();
return is_event;
}
}
@Override
public String getNamePrefix() {
return "Qualify";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy