automapper_validation/generated/fv2504/
contrl_conditions_fv2504.rs1#![allow(clippy::style, clippy::complexity)]
11
12#[allow(unused_imports)]
13use crate::eval::format_validators::*;
14use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
15
16pub struct ContrlConditionEvaluatorFV2504 {
18 external_conditions: std::collections::HashSet<u32>,
20}
21
22impl Default for ContrlConditionEvaluatorFV2504 {
23 fn default() -> Self {
24 let mut external_conditions = std::collections::HashSet::new();
25 external_conditions.insert(1);
26 Self {
27 external_conditions,
28 }
29 }
30}
31
32impl ConditionEvaluator for ContrlConditionEvaluatorFV2504 {
33 fn message_type(&self) -> &str {
34 "CONTRL"
35 }
36
37 fn format_version(&self) -> &str {
38 "FV2504"
39 }
40
41 fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
42 match condition {
43 1 => self.evaluate_1(ctx),
44 2 => self.evaluate_2(ctx),
45 3 => self.evaluate_3(ctx),
46 5 => self.evaluate_5(ctx),
47 6 => self.evaluate_6(ctx),
48 8 => self.evaluate_8(ctx),
49 9 => self.evaluate_9(ctx),
50 _ => ConditionResult::Unknown,
51 }
52 }
53
54 fn is_external(&self, condition: u32) -> bool {
55 self.external_conditions.contains(&condition)
56 }
57 fn is_known(&self, condition: u32) -> bool {
58 matches!(condition, 1 | 2 | 3 | 5 | 6 | 8 | 9)
59 }
60}
61
62impl ContrlConditionEvaluatorFV2504 {
63 fn evaluate_1(&self, ctx: &EvaluationContext) -> ConditionResult {
67 ctx.external.evaluate("angabe_moeglich")
68 }
69
70 fn evaluate_2(&self, ctx: &EvaluationContext) -> ConditionResult {
72 let ucm_segments = ctx.find_segments("UCM");
73 ConditionResult::from(ucm_segments.iter().any(|s| {
74 let has_unh = s
75 .elements
76 .get(4)
77 .and_then(|e| e.first())
78 .is_some_and(|v| v == "UNH");
79 let has_error = s
80 .elements
81 .get(3)
82 .and_then(|e| e.first())
83 .is_some_and(|v| !v.is_empty());
84 has_unh && has_error
85 }))
86 }
87
88 fn evaluate_3(&self, ctx: &EvaluationContext) -> ConditionResult {
90 let ucm_segments = ctx.find_segments("UCM");
91 ConditionResult::from(ucm_segments.iter().any(|s| {
92 let has_unt = s
93 .elements
94 .get(4)
95 .and_then(|e| e.first())
96 .is_some_and(|v| v == "UNT");
97 let has_error = s
98 .elements
99 .get(3)
100 .and_then(|e| e.first())
101 .is_some_and(|v| !v.is_empty());
102 has_unt && has_error
103 }))
104 }
105
106 fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
109 let ucm_segments = ctx.find_segments("UCM");
110 ConditionResult::from(ucm_segments.iter().any(|s| {
111 let has_error = s
112 .elements
113 .get(3)
114 .and_then(|e| e.first())
115 .is_some_and(|v| !v.is_empty());
116 let has_element_detail = s
118 .elements
119 .get(5)
120 .and_then(|e| e.first())
121 .is_some_and(|v| !v.is_empty());
122 has_error && !has_element_detail
123 }))
124 }
125
126 fn evaluate_6(&self, ctx: &EvaluationContext) -> ConditionResult {
129 let ucm_segments = ctx.find_segments("UCM");
130 ConditionResult::from(ucm_segments.iter().any(|s| {
131 s.elements
133 .get(5)
134 .and_then(|e| e.first())
135 .is_some_and(|v| !v.is_empty())
136 }))
137 }
138
139 fn evaluate_8(&self, ctx: &EvaluationContext) -> ConditionResult {
141 let ucm_segments = ctx.find_segments("UCM");
142 ConditionResult::from(ucm_segments.iter().any(|s| {
143 s.elements
144 .get(4)
145 .and_then(|e| e.first())
146 .is_some_and(|v| !v.is_empty())
147 }))
148 }
149
150 fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
152 let ucm_segments = ctx.find_segments("UCM");
153 if ucm_segments.is_empty() {
154 return ConditionResult::Unknown;
155 }
156 ConditionResult::from(ucm_segments.iter().all(|s| {
157 !s.elements
158 .get(4)
159 .and_then(|e| e.first())
160 .is_some_and(|v| !v.is_empty())
161 }))
162 }
163}