cdm.base.staticdata.asset.common.validation.datarule.CollateralTaxonomyUkEligibleCollateralTaxonomy Maven / Gradle / Ivy
package cdm.base.staticdata.asset.common.validation.datarule;
import cdm.base.staticdata.asset.common.CollateralTaxonomy;
import cdm.base.staticdata.asset.common.CollateralTaxonomyValue;
import cdm.base.staticdata.asset.common.TaxonomySourceEnum;
import cdm.base.staticdata.asset.common.UK_EMIR_EligibleCollateralEnum;
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.63
*/
@RosettaDataRule("CollateralTaxonomyUkEligibleCollateralTaxonomy")
@ImplementedBy(CollateralTaxonomyUkEligibleCollateralTaxonomy.Default.class)
public interface CollateralTaxonomyUkEligibleCollateralTaxonomy extends Validator {
String NAME = "CollateralTaxonomyUkEligibleCollateralTaxonomy";
String DEFINITION = "if taxonomySource = TaxonomySourceEnum -> UK_EMIR_EligibleCollateralAssetClass then taxonomyValue -> uk_EMIR_EligibleCollateral exists";
ValidationResult validate(RosettaPath path, CollateralTaxonomy collateralTaxonomy);
class Default implements CollateralTaxonomyUkEligibleCollateralTaxonomy {
@Override
public ValidationResult validate(RosettaPath path, CollateralTaxonomy collateralTaxonomy) {
ComparisonResult result = executeDataRule(collateralTaxonomy);
if (result.get()) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "CollateralTaxonomy", path, DEFINITION);
}
String failureMessage = result.getError();
if (failureMessage == null || failureMessage.contains("Null") || failureMessage == "") {
failureMessage = "Condition has failed.";
}
return ValidationResult.failure(NAME, ValidationType.DATA_RULE, "CollateralTaxonomy", path, DEFINITION, failureMessage);
}
private ComparisonResult executeDataRule(CollateralTaxonomy collateralTaxonomy) {
try {
if (areEqual(MapperS.of(collateralTaxonomy).map("getTaxonomySource", _collateralTaxonomy -> _collateralTaxonomy.getTaxonomySource()), MapperS.of(TaxonomySourceEnum.UK_EMIR_ELIGIBLE_COLLATERAL_ASSET_CLASS), CardinalityOperator.All).getOrDefault(false)) {
return exists(MapperS.of(collateralTaxonomy).map("getTaxonomyValue", _collateralTaxonomy -> _collateralTaxonomy.getTaxonomyValue()).mapC("getUk_EMIR_EligibleCollateral", collateralTaxonomyValue -> collateralTaxonomyValue.getUk_EMIR_EligibleCollateral()));
}
return ComparisonResult.successEmptyOperand("");
}
catch (Exception ex) {
return ComparisonResult.failure(ex.getMessage());
}
}
}
@SuppressWarnings("unused")
class NoOp implements CollateralTaxonomyUkEligibleCollateralTaxonomy {
@Override
public ValidationResult validate(RosettaPath path, CollateralTaxonomy collateralTaxonomy) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "CollateralTaxonomy", path, DEFINITION);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy