1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
use super::style::Style;
use super::color::Color;

#[derive(Clone, Debug)]
pub struct Conditional {
    condition_type: String,
    operator_type : String,
    data_type: String,
    text: String,
    priority: usize,
    percent: usize,
    bottom: usize,
    rank: usize,
    stop_if_true : bool,
    condition: Vec<String>,
    cfvo_collection: Vec<(String, Option<String>, Option<Color>)>,
    style: Option<Style>,
}
impl Default for Conditional {
    fn default() -> Self {
        Self {
            condition_type: Conditional::CONDITION_NONE.to_string(),
            operator_type : Conditional::OPERATOR_NONE.to_string(),
            data_type: "".into(),
            text: "".into(),
            priority: 0,
            percent: 0,
            bottom: 0,
            rank: 0,
            stop_if_true : false,
            condition: Vec::new(),
            cfvo_collection: Vec::new(),
            style: None
        }
    }
}
impl Conditional {
    // Condition types

    pub const CONDITION_NONE: &'static str = "none";
    pub const CONDITION_CELLIS: &'static str = "cellIs";
    pub const CONDITION_CONTAINSTEXT: &'static str = "containsText";
    pub const CONDITION_EXPRESSION: &'static str = "expression";
    pub const CONDITION_CONTAINSBLANKS: &'static str = "containsBlanks";
    pub const CONDITION_NOTCONTAINSBLANKS: &'static str = "notContainsBlanks";
    
    // Operator types

    pub const OPERATOR_NONE: &'static str = "";
    pub const OPERATOR_BEGINSWITH: &'static str = "beginsWith";
    pub const OPERATOR_ENDSWITH: &'static str = "endsWith";
    pub const OPERATOR_EQUAL: &'static str = "equal";
    pub const OPERATOR_GREATERTHAN: &'static str = "greaterThan";
    pub const OPERATOR_GREATERTHANOREQUAL: &'static str = "greaterThanOrEqual";
    pub const OPERATOR_LESSTHAN: &'static str = "lessThan";
    pub const OPERATOR_LESSTHANOREQUAL: &'static str = "lessThanOrEqual";
    pub const OPERATOR_NOTEQUAL: &'static str = "notEqual";
    pub const OPERATOR_CONTAINSTEXT: &'static str = "containsText";
    pub const OPERATOR_NOTCONTAINS: &'static str = "notContains";
    pub const OPERATOR_BETWEEN: &'static str = "between";
    pub const OPERATOR_NOTBETWEEN: &'static str = "notBetween";

    pub fn get_condition_type(&self)-> &str {
        &self.condition_type
    }
    pub(crate) fn set_condition_type<S: Into<String>>(&mut self, value:S) {
        self.condition_type = value.into();
    }
    pub fn get_operator_type(&self)-> &str {
        &self.operator_type
    }
    pub(crate) fn set_operator_type<S: Into<String>>(&mut self, value:S) {
        self.operator_type = value.into();
    }
    pub fn get_data_type(&self)-> &str {
        &self.data_type
    }
    pub(crate) fn set_data_type<S: Into<String>>(&mut self, value:S) {
        self.data_type = value.into();
    }
    pub fn get_text(&self)-> &str {
        &self.text
    }
    pub(crate) fn set_text<S: Into<String>>(&mut self, value:S) {
        self.text = value.into();
    }
    pub fn get_priority(&self)-> &usize {
        &self.priority
    }
    pub(crate) fn set_priority(&mut self, value:usize) {
        self.priority = value;
    }
    pub fn get_percent(&self)-> &usize {
        &self.percent
    }
    pub(crate) fn set_percent(&mut self, value:usize) {
        self.percent = value;
    }
    pub fn get_bottom(&self)-> &usize {
        &self.bottom
    }
    pub(crate) fn set_bottom(&mut self, value:usize) {
        self.bottom = value;
    }
    pub fn get_rank(&self)-> &usize {
        &self.rank
    }
    pub(crate) fn set_rank(&mut self, value:usize) {
        self.rank = value;
    }
    pub fn get_stop_if_true(&self)-> &bool {
        &self.stop_if_true
    }
    pub(crate) fn set_stop_if_true(&mut self, value:bool) {
        self.stop_if_true = value;
    }
    pub fn get_condition(&self)-> &Vec<String> {
        &self.condition
    }
    pub(crate) fn set_condition(&mut self, value:Vec<String>) {
        self.condition = value;
    }
    pub(crate) fn add_condition<S: Into<String>>(&mut self, value:S) {
        self.condition.push(value.into());
    }
    pub fn get_cfvo_collection(&self)-> &Vec<(String, Option<String>, Option<Color>)> {
        &self.cfvo_collection
    }
    pub(crate) fn set_cfvo_collection(&mut self, value:Vec<(String, Option<String>, Option<Color>)>) {
        self.cfvo_collection = value;
    }
    pub(crate) fn add_cfvo_collection<S: Into<String>>(&mut self, r#type:S, value:Option<String>, color:Option<Color>) {
        self.cfvo_collection.push((r#type.into(), value, color));
    }
    pub fn get_style(&self)-> &Option<Style> {
        &self.style
    }
    pub(crate) fn set_style(&mut self, value:Style) {
        self.style = Some(value);
    }
}