cdm.product.template.validation.datarule.TradableProductExerciseNoticeReceiverPartyExtendibleProvision Maven / Gradle / Ivy
package cdm.product.template.validation.datarule;
import cdm.base.staticdata.party.AncillaryParty;
import cdm.base.staticdata.party.AncillaryRoleEnum;
import cdm.product.template.EconomicTerms;
import cdm.product.template.ExerciseNotice;
import cdm.product.template.ExtendibleProvision;
import cdm.product.template.NonTransferableProduct;
import cdm.product.template.TerminationProvision;
import cdm.product.template.TradableProduct;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.annotations.RosettaDataRule;
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("TradableProductExerciseNoticeReceiverPartyExtendibleProvision")
@ImplementedBy(TradableProductExerciseNoticeReceiverPartyExtendibleProvision.Default.class)
public interface TradableProductExerciseNoticeReceiverPartyExtendibleProvision extends Validator {
String NAME = "TradableProductExerciseNoticeReceiverPartyExtendibleProvision";
String DEFINITION = "if product -> economicTerms -> terminationProvision -> extendibleProvision -> exerciseNotice -> exerciseNoticeReceiver exists then ancillaryParty -> role contains AncillaryRoleEnum -> ExerciseNoticeReceiverPartyExtendibleProvision and if ancillaryParty -> role contains AncillaryRoleEnum -> ExerciseNoticeReceiverPartyExtendibleProvision then product -> economicTerms -> terminationProvision -> extendibleProvision -> exerciseNotice -> exerciseNoticeReceiver exists";
ValidationResult validate(RosettaPath path, TradableProduct tradableProduct);
class Default implements TradableProductExerciseNoticeReceiverPartyExtendibleProvision {
@Override
public ValidationResult validate(RosettaPath path, TradableProduct tradableProduct) {
ComparisonResult result = executeDataRule(tradableProduct);
if (result.get()) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "TradableProduct", path, DEFINITION);
}
String failureMessage = result.getError();
if (failureMessage == null || failureMessage.contains("Null") || failureMessage == "") {
failureMessage = "Condition has failed.";
}
return ValidationResult.failure(NAME, ValidationType.DATA_RULE, "TradableProduct", path, DEFINITION, failureMessage);
}
private ComparisonResult executeDataRule(TradableProduct tradableProduct) {
try {
if (exists(MapperS.of(tradableProduct).map("getProduct", _tradableProduct -> _tradableProduct.getProduct()).map("getEconomicTerms", nonTransferableProduct -> nonTransferableProduct.getEconomicTerms()).map("getTerminationProvision", economicTerms -> economicTerms.getTerminationProvision()).map("getExtendibleProvision", terminationProvision -> terminationProvision.getExtendibleProvision()).map("getExerciseNotice", extendibleProvision -> extendibleProvision.getExerciseNotice()).map("getExerciseNoticeReceiver", exerciseNotice -> exerciseNotice.getExerciseNoticeReceiver())).getOrDefault(false)) {
final ComparisonResult ifThenElseResult;
if (contains(MapperS.of(tradableProduct).mapC("getAncillaryParty", _tradableProduct -> _tradableProduct.getAncillaryParty()).map("getRole", ancillaryParty -> ancillaryParty.getRole()), MapperS.of(AncillaryRoleEnum.EXERCISE_NOTICE_RECEIVER_PARTY_EXTENDIBLE_PROVISION)).getOrDefault(false)) {
ifThenElseResult = exists(MapperS.of(tradableProduct).map("getProduct", _tradableProduct -> _tradableProduct.getProduct()).map("getEconomicTerms", nonTransferableProduct -> nonTransferableProduct.getEconomicTerms()).map("getTerminationProvision", economicTerms -> economicTerms.getTerminationProvision()).map("getExtendibleProvision", terminationProvision -> terminationProvision.getExtendibleProvision()).map("getExerciseNotice", extendibleProvision -> extendibleProvision.getExerciseNotice()).map("getExerciseNoticeReceiver", exerciseNotice -> exerciseNotice.getExerciseNoticeReceiver()));
} else {
ifThenElseResult = ComparisonResult.successEmptyOperand("");
}
return contains(MapperS.of(tradableProduct).mapC("getAncillaryParty", _tradableProduct -> _tradableProduct.getAncillaryParty()).map("getRole", ancillaryParty -> ancillaryParty.getRole()), MapperS.of(AncillaryRoleEnum.EXERCISE_NOTICE_RECEIVER_PARTY_EXTENDIBLE_PROVISION)).and(ifThenElseResult);
}
return ComparisonResult.successEmptyOperand("");
}
catch (Exception ex) {
return ComparisonResult.failure(ex.getMessage());
}
}
}
@SuppressWarnings("unused")
class NoOp implements TradableProductExerciseNoticeReceiverPartyExtendibleProvision {
@Override
public ValidationResult validate(RosettaPath path, TradableProduct tradableProduct) {
return ValidationResult.success(NAME, ValidationResult.ValidationType.DATA_RULE, "TradableProduct", path, DEFINITION);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy