cdm.product.collateral.functions.CheckAgencyRating Maven / Gradle / Ivy
package cdm.product.collateral.functions;
import cdm.base.math.QuantifierEnum;
import cdm.observable.asset.CreditNotation;
import cdm.observable.asset.CreditRatingAgencyEnum;
import cdm.product.collateral.AgencyRatingCriteria;
import cdm.product.collateral.EligibilityQuery;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.ComparisonResult;
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.metafields.FieldWithMetaString;
import java.util.Collections;
import java.util.List;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(CheckAgencyRating.CheckAgencyRatingDefault.class)
public abstract class CheckAgencyRating implements RosettaFunction {
/**
* @param agencyRatings
* @param query
* @return isEqual
*/
public Boolean evaluate(List extends AgencyRatingCriteria> agencyRatings, EligibilityQuery query) {
Boolean isEqual = doEvaluate(agencyRatings, query);
return isEqual;
}
protected abstract Boolean doEvaluate(List extends AgencyRatingCriteria> agencyRatings, EligibilityQuery query);
public static class CheckAgencyRatingDefault extends CheckAgencyRating {
@Override
protected Boolean doEvaluate(List extends AgencyRatingCriteria> agencyRatings, EligibilityQuery query) {
if (agencyRatings == null) {
agencyRatings = Collections.emptyList();
}
Boolean isEqual = null;
return assignOutput(isEqual, agencyRatings, query);
}
protected Boolean assignOutput(Boolean isEqual, List extends AgencyRatingCriteria> agencyRatings, EligibilityQuery query) {
final MapperC thenResult0 = MapperC.of(agencyRatings);
final MapperC thenResult1 = thenResult0
.filterItemNullSafe(item -> contains(item.mapC("getCreditNotation", agencyRatingCriteria -> agencyRatingCriteria.getCreditNotation()).map("getNotation", creditNotation -> creditNotation.getNotation()).map("Type coercion", fieldWithMetaString -> fieldWithMetaString.getValue()), MapperS.of(query).map("getAgencyRating", eligibilityQuery -> eligibilityQuery.getAgencyRating()).mapC("getCreditNotation", agencyRatingCriteria -> agencyRatingCriteria.getCreditNotation()).map("getNotation", creditNotation -> creditNotation.getNotation()).map("Type coercion", fieldWithMetaString -> fieldWithMetaString.getValue())).get());
final MapperC thenResult2 = thenResult1
.filterItemNullSafe(item -> contains(item.map("getQualifier", agencyRatingCriteria -> agencyRatingCriteria.getQualifier()), MapperS.of(query).map("getAgencyRating", eligibilityQuery -> eligibilityQuery.getAgencyRating()).map("getQualifier", agencyRatingCriteria -> agencyRatingCriteria.getQualifier())).get());
final MapperC thenResult3 = thenResult2
.filterItemNullSafe(item -> notExists(item.map("getReferenceAgency", agencyRatingCriteria -> agencyRatingCriteria.getReferenceAgency())).or(contains(item.map("getReferenceAgency", agencyRatingCriteria -> agencyRatingCriteria.getReferenceAgency()), MapperS.of(query).map("getAgencyRating", eligibilityQuery -> eligibilityQuery.getAgencyRating()).map("getReferenceAgency", agencyRatingCriteria -> agencyRatingCriteria.getReferenceAgency()))).get());
isEqual = notExists(MapperC.of(agencyRatings)).or(ComparisonResult.of(exists(thenResult3).asMapper())).get();
return isEqual;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy