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

cdm.event.qualification.functions.Qualify_CreditEventDetermined Maven / Gradle / Ivy

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

import cdm.event.common.BusinessEvent;
import cdm.event.common.CreditEvent;
import cdm.event.common.Instruction;
import cdm.event.common.ObservationEvent;
import cdm.event.common.ObservationInstruction;
import cdm.event.common.PrimitiveInstruction;
import cdm.event.common.TradeState;
import cdm.event.common.metafields.ReferenceWithMetaTradeState;
import com.google.inject.ImplementedBy;
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_CreditEventDetermined.Qualify_CreditEventDeterminedDefault.class)
public abstract class Qualify_CreditEventDetermined 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);

	public static class Qualify_CreditEventDeterminedDefault extends Qualify_CreditEventDetermined {
		@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(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).map("getPrimitiveInstruction", instruction -> instruction.getPrimitiveInstruction()).map("getObservation", primitiveInstruction -> primitiveInstruction.getObservation()).map("getObservationEvent", observationInstruction -> observationInstruction.getObservationEvent()).map("getCreditEvent", observationEvent -> observationEvent.getCreditEvent())).or(exists(MapperS.of(businessEvent).mapC("getInstruction", _businessEvent -> _businessEvent.getInstruction()).map("getBefore", instruction -> instruction.getBefore()).map("getValue", _f->_f.getValue()).mapC("getObservationHistory", tradeState -> tradeState.getObservationHistory()).map("getCreditEvent", observationEvent -> observationEvent.getCreditEvent()))).or(exists(MapperS.of(businessEvent).mapC("getAfter", _businessEvent -> _businessEvent.getAfter()).mapC("getObservationHistory", tradeState -> tradeState.getObservationHistory()).map("getCreditEvent", observationEvent -> observationEvent.getCreditEvent()))).get();
			
			return is_event;
		}
	}
		
		@Override
		public String getNamePrefix() {
			return "Qualify";
		}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy