cdm.event.qualification.functions.Qualify_Reset Maven / Gradle / Ivy
package cdm.event.qualification.functions;
import cdm.event.common.BusinessEvent;
import cdm.event.common.Instruction;
import cdm.event.common.Reset;
import cdm.event.common.Trade;
import cdm.event.common.TradeState;
import cdm.event.common.metafields.ReferenceWithMetaTradeState;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.CardinalityOperator;
import com.rosetta.model.lib.expression.MapperMaths;
import com.rosetta.model.lib.functions.IQualifyFunctionExtension;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(Qualify_Reset.Qualify_ResetDefault.class)
public abstract class Qualify_Reset implements RosettaFunction,IQualifyFunctionExtension {
/**
* @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 MapperS beforeTradeState(BusinessEvent businessEvent);
protected abstract MapperS extends TradeState> afterTradeState(BusinessEvent businessEvent);
public static class Qualify_ResetDefault extends Qualify_Reset {
@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(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).resultCount()), MapperS.of(1), CardinalityOperator.All).and(areEqual(beforeTradeState(businessEvent).map("Type coercion", referenceWithMetaTradeState0 -> referenceWithMetaTradeState0 == null ? null : referenceWithMetaTradeState0.getValue()).map("getTrade", tradeState -> tradeState.getTrade()), afterTradeState(businessEvent).map("getTrade", tradeState -> tradeState.getTrade()), CardinalityOperator.All)).and(areEqual(MapperMaths.add(MapperS.of(beforeTradeState(businessEvent).map("Type coercion", referenceWithMetaTradeState1 -> referenceWithMetaTradeState1 == null ? null : referenceWithMetaTradeState1.getValue()).mapC("getResetHistory", tradeState -> tradeState.getResetHistory()).resultCount()), MapperS.of(1)), MapperS.of(afterTradeState(businessEvent).mapC("getResetHistory", tradeState -> tradeState.getResetHistory()).resultCount()), CardinalityOperator.All)).get();
return is_event;
}
@Override
protected MapperS beforeTradeState(BusinessEvent businessEvent) {
return MapperS.of(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).map("getBefore", instruction -> instruction.getBefore()).get());
}
@Override
protected MapperS extends TradeState> afterTradeState(BusinessEvent businessEvent) {
return MapperS.of(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).get());
}
}
@Override
public String getNamePrefix() {
return "Qualify";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy