cdm.product.collateral.validation.datarule.EligibleCollateralCriteriaAverageTradingVolumeEquityOnly Maven / Gradle / Ivy
package cdm.product.collateral.validation.datarule;
import cdm.base.staticdata.asset.common.AssetType;
import cdm.base.staticdata.asset.common.InstrumentTypeEnum;
import cdm.product.collateral.AssetCriteria;
import cdm.product.collateral.AverageTradingVolume;
import cdm.product.collateral.CollateralTreatment;
import cdm.product.collateral.ConcentrationLimit;
import cdm.product.collateral.ConcentrationLimitCriteria;
import cdm.product.collateral.EligibleCollateralCriteria;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.annotations.RosettaDataRule;
import com.rosetta.model.lib.expression.CardinalityOperator;
import com.rosetta.model.lib.expression.ComparisonResult;
import com.rosetta.model.lib.mapper.MapperS;
import com.rosetta.model.lib.path.RosettaPath;
import com.rosetta.model.lib.validation.ValidationResult;
import com.rosetta.model.lib.validation.ValidationResult.ValidationType;
import com.rosetta.model.lib.validation.Validator;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
/**
* @version 6.0.0-dev.82
*/
@RosettaDataRule("EligibleCollateralCriteriaAverageTradingVolumeEquityOnly")
@ImplementedBy(EligibleCollateralCriteriaAverageTradingVolumeEquityOnly.Default.class)
public interface EligibleCollateralCriteriaAverageTradingVolumeEquityOnly extends Validator {
String NAME = "EligibleCollateralCriteriaAverageTradingVolumeEquityOnly";
String DEFINITION = "if treatment -> concentrationLimit -> concentrationLimitCriteria -> averageTradingVolume exists then asset -> collateralAssetType -> securityType all = InstrumentTypeEnum -> Equity or treatment -> concentrationLimit -> concentrationLimitCriteria -> asset -> collateralAssetType -> securityType all = InstrumentTypeEnum -> Equity";
ValidationResult validate(RosettaPath path, EligibleCollateralCriteria eligibleCollateralCriteria);
class Default implements EligibleCollateralCriteriaAverageTradingVolumeEquityOnly {
@Override
public ValidationResult validate(RosettaPath path, EligibleCollateralCriteria eligibleCollateralCriteria) {
ComparisonResult result = executeDataRule(eligibleCollateralCriteria);
if (result.get()) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "EligibleCollateralCriteria", path, DEFINITION);
}
String failureMessage = result.getError();
if (failureMessage == null || failureMessage.contains("Null") || failureMessage == "") {
failureMessage = "Condition has failed.";
}
return ValidationResult.failure(NAME, ValidationType.DATA_RULE, "EligibleCollateralCriteria", path, DEFINITION, failureMessage);
}
private ComparisonResult executeDataRule(EligibleCollateralCriteria eligibleCollateralCriteria) {
try {
if (exists(MapperS.of(eligibleCollateralCriteria).map("getTreatment", _eligibleCollateralCriteria -> _eligibleCollateralCriteria.getTreatment()).mapC("getConcentrationLimit", collateralTreatment -> collateralTreatment.getConcentrationLimit()).mapC("getConcentrationLimitCriteria", concentrationLimit -> concentrationLimit.getConcentrationLimitCriteria()).map("getAverageTradingVolume", concentrationLimitCriteria -> concentrationLimitCriteria.getAverageTradingVolume())).getOrDefault(false)) {
return areEqual(MapperS.of(eligibleCollateralCriteria).mapC("getAsset", _eligibleCollateralCriteria -> _eligibleCollateralCriteria.getAsset()).mapC("getCollateralAssetType", assetCriteria -> assetCriteria.getCollateralAssetType()).map("getSecurityType", assetType -> assetType.getSecurityType()), MapperS.of(InstrumentTypeEnum.EQUITY), CardinalityOperator.All).or(areEqual(MapperS.of(eligibleCollateralCriteria).map("getTreatment", _eligibleCollateralCriteria -> _eligibleCollateralCriteria.getTreatment()).mapC("getConcentrationLimit", collateralTreatment -> collateralTreatment.getConcentrationLimit()).mapC("getConcentrationLimitCriteria", concentrationLimit -> concentrationLimit.getConcentrationLimitCriteria()).mapC("getAsset", concentrationLimitCriteria -> concentrationLimitCriteria.getAsset()).mapC("getCollateralAssetType", assetCriteria -> assetCriteria.getCollateralAssetType()).map("getSecurityType", assetType -> assetType.getSecurityType()), MapperS.of(InstrumentTypeEnum.EQUITY), CardinalityOperator.All));
}
return ComparisonResult.successEmptyOperand("");
}
catch (Exception ex) {
return ComparisonResult.failure(ex.getMessage());
}
}
}
@SuppressWarnings("unused")
class NoOp implements EligibleCollateralCriteriaAverageTradingVolumeEquityOnly {
@Override
public ValidationResult validate(RosettaPath path, EligibleCollateralCriteria eligibleCollateralCriteria) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "EligibleCollateralCriteria", path, DEFINITION);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy