cdm.event.qualification.functions.Qualify_CashAndSecurityTransfer Maven / Gradle / Ivy
package cdm.event.qualification.functions;
import cdm.base.math.FinancialUnitEnum;
import cdm.base.math.NonNegativeQuantity;
import cdm.base.math.UnitType;
import cdm.event.common.BusinessEvent;
import cdm.event.common.TradeState;
import cdm.event.common.Transfer;
import cdm.event.common.TransferState;
import cdm.event.common.functions.TransfersForDate;
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.MapperC;
import com.rosetta.model.lib.mapper.MapperS;
import com.rosetta.model.lib.records.Date;
import com.rosetta.model.metafields.FieldWithMetaString;
import javax.inject.Inject;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(Qualify_CashAndSecurityTransfer.Qualify_CashAndSecurityTransferDefault.class)
public abstract class Qualify_CashAndSecurityTransfer implements RosettaFunction,IQualifyFunctionExtension {
// RosettaFunction dependencies
//
@Inject protected TransfersForDate transfersForDate0;
/**
* @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);
protected abstract MapperC extends Transfer> transfersForDate1(BusinessEvent businessEvent);
public static class Qualify_CashAndSecurityTransferDefault extends Qualify_CashAndSecurityTransfer {
@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 = exists(transfersForDate1(businessEvent).map("getQuantity", transfer -> transfer.getQuantity()).map("getUnit", nonNegativeQuantity -> nonNegativeQuantity.getUnit()).map("getCurrency", unitType -> unitType.getCurrency())).and(exists(transfersForDate1(businessEvent).map("getQuantity", transfer -> transfer.getQuantity()).map("getUnit", nonNegativeQuantity -> nonNegativeQuantity.getUnit()).map("getFinancialUnit", unitType -> unitType.getFinancialUnit()))).and(areEqual(MapperS.of(transfersForDate1(businessEvent).resultCount()), MapperS.of(2), CardinalityOperator.All)).get();
return is_event;
}
@Override
protected MapperC extends Transfer> transfersForDate1(BusinessEvent businessEvent) {
return MapperC.of(transfersForDate0.evaluate(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).mapC("getTransferHistory", tradeState -> tradeState.getTransferHistory()).map("getTransfer", transferState -> transferState.getTransfer()).getMulti(), MapperS.of(businessEvent).map("getEventDate", _businessEvent -> _businessEvent.getEventDate()).get()));
}
}
@Override
public String getNamePrefix() {
return "Qualify";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy