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

cdm.product.qualification.functions.InterestRatePayoutOnlyExists Maven / Gradle / Ivy

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

import cdm.product.asset.InterestRatePayout;
import cdm.product.template.Payout;
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.MapperC;
import com.rosetta.model.lib.mapper.MapperS;
import java.util.Collections;
import java.util.List;

import static com.rosetta.model.lib.expression.ExpressionOperators.*;

@ImplementedBy(InterestRatePayoutOnlyExists.InterestRatePayoutOnlyExistsDefault.class)
public abstract class InterestRatePayoutOnlyExists implements RosettaFunction {

	/**
	* @param payouts 
	* @return result 
	*/
	public Boolean evaluate(List payouts) {
		Boolean result = doEvaluate(payouts);
		
		return result;
	}

	protected abstract Boolean doEvaluate(List payouts);

	public static class InterestRatePayoutOnlyExistsDefault extends InterestRatePayoutOnlyExists {
		@Override
		protected Boolean doEvaluate(List payouts) {
			if (payouts == null) {
				payouts = Collections.emptyList();
			}
			Boolean result = null;
			return assignOutput(result, payouts);
		}
		
		protected Boolean assignOutput(Boolean result, List payouts) {
			final MapperC thenResult0 = MapperC.of(payouts)
				.mapItem(item -> exists(item.map("getInterestRatePayout", payout -> payout.getInterestRatePayout())).asMapper());
			final MapperS thenResult1 = areEqual(thenResult0, MapperS.of(true), CardinalityOperator.All).asMapper();
			result = MapperS.of(thenResult1.getOrDefault(false)).get();
			
			return result;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy