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