automapper-validation 0.1.57

AHB condition expression parsing, evaluation, and EDIFACT validation
Documentation
// <auto-generated>
// Generated by automapper-generator generate-conditions
// AHB: xml-migs-and-ahbs/FV2610/UTILMD_AHB_Gas_1_2_20260401.xml
// Generated: 2026-04-22T18:01:29Z
// Delegates unchanged conditions to UtilmdGasConditionEvaluatorFV2604 (FV2604).
// </auto-generated>

#![allow(clippy::style, clippy::complexity)]

#[allow(unused_imports)]
use crate::eval::format_validators::*;
use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
use crate::generated::fv2604::UtilmdGasConditionEvaluatorFV2604;

/// Condition evaluator for UTILMD_Gas FV2610.
///
/// Delegates to [`UtilmdGasConditionEvaluatorFV2604`] for conditions whose AHB description is
/// unchanged from that version. Local overrides: [203].
pub struct UtilmdGasConditionEvaluatorFV2610 {
    fallback: UtilmdGasConditionEvaluatorFV2604,
}

impl Default for UtilmdGasConditionEvaluatorFV2610 {
    fn default() -> Self {
        Self {
            fallback: UtilmdGasConditionEvaluatorFV2604::default(),
        }
    }
}

/// Condition IDs whose implementation differs from the fallback.
const FV2610_OVERRIDES: &[u32] = &[203];

impl ConditionEvaluator for UtilmdGasConditionEvaluatorFV2610 {
    fn message_type(&self) -> &str {
        "UTILMD_Gas"
    }

    fn format_version(&self) -> &str {
        "FV2610"
    }

    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
        match condition {
            203 => self.evaluate_203(ctx),
            other => self.fallback.evaluate(other, ctx),
        }
    }

    fn is_external(&self, condition: u32) -> bool {
        self.fallback.is_external(condition)
    }

    fn is_known(&self, condition: u32) -> bool {
        FV2610_OVERRIDES.contains(&condition) || self.fallback.is_known(condition)
    }
}

impl UtilmdGasConditionEvaluatorFV2610 {
    /// [203] Wenn STS+7++E06 / Z39 / ZC6 / ZC7 / ZT6 / ZT7 / Z02 / ZZD
    fn evaluate_203(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value(
            "STS",
            0,
            "7",
            2,
            0,
            &["E06", "Z39", "ZC6", "ZC7", "ZT6", "ZT7", "Z02", "ZZD"],
        )
    }
}