#[derive(Debug, serde::Serialize, Default, Clone)]
pub struct DslIfCondition {
pub name: String, pub value: String, pub operator: String, pub next_condition_type: String, }
impl DslIfCondition {
pub fn rust_value(&self) -> &str {
match self.value.to_lowercase().as_str() {
"null" => "None",
_ => self.value.as_str(),
}
}
pub fn condition_src(&self, need_param: bool) -> String {
let var_name = if need_param {
format!("param.{}", self.name)
} else {
self.name.clone()
};
let mut body = String::new();
body.push_str(&var_name);
body.push_str(" ");
body.push_str(&self.operator);
body.push_str(" ");
body.push_str(&self.rust_value());
body.push_str(" ");
body.push_str(&self.next_condition_type);
body.push_str(" ");
body
}
}