1
use crate::model::component::{
2
    add_attach, add_categories, add_class, add_comment, add_contact, add_created,
3
    add_date_time_stamp, add_date_time_start, add_description, add_exception_date_times,
4
    add_last_modified, add_organizer, add_recurrence_date, add_recurrence_id, add_recurrence_rule,
5
    add_related, add_request_status, add_sequence, add_summary, add_unique_identifier, add_url,
6
    impl_finish_component_build, impl_other_component_properties, CalendarComponent,
7
};
8
use crate::model::impl_component_access;
9
use crate::model::object::ICalObjectBuilder;
10
use crate::model::param::ParticipationStatusJournal;
11
use crate::model::property::{
12
    AddComponentProperty, AttendeePropertyBuilder, ComponentProperty, IanaComponentPropertyBuilder,
13
    StatusJournal, StatusPropertyBuilder, XComponentPropertyBuilder,
14
};
15

            
16
#[derive(Debug, PartialEq)]
17
pub struct JournalComponent {
18
    pub(crate) properties: Vec<ComponentProperty>,
19
}
20

            
21
impl_component_access!(JournalComponent);
22

            
23
impl JournalComponent {
24
14
    pub(crate) fn new() -> Self {
25
14
        JournalComponent {
26
14
            properties: Vec::new(),
27
14
        }
28
14
    }
29
}
30

            
31
impl Default for JournalComponent {
32
    fn default() -> Self {
33
        Self::new()
34
    }
35
}
36

            
37
pub struct JournalComponentBuilder {
38
    owner: ICalObjectBuilder,
39
    inner: JournalComponent,
40
}
41

            
42
impl JournalComponentBuilder {
43
14
    pub(crate) fn new(owner: ICalObjectBuilder) -> Self {
44
14
        JournalComponentBuilder {
45
14
            owner,
46
14
            inner: JournalComponent {
47
14
                properties: Vec::new(),
48
14
            },
49
14
        }
50
14
    }
51

            
52
    add_date_time_stamp!();
53

            
54
    add_unique_identifier!();
55

            
56
    add_class!();
57

            
58
    add_created!();
59

            
60
    add_date_time_start!();
61

            
62
    add_last_modified!();
63

            
64
    add_organizer!();
65

            
66
    add_recurrence_id!();
67

            
68
    add_sequence!();
69

            
70
12
    pub fn add_status(self, value: StatusJournal) -> StatusPropertyBuilder<Self> {
71
12
        StatusPropertyBuilder::new(self, value.into())
72
12
    }
73

            
74
    add_summary!();
75

            
76
    add_url!();
77

            
78
    add_recurrence_rule!();
79

            
80
    add_attach!();
81

            
82
12
    pub fn add_attendee(
83
12
        self,
84
12
        value: &str,
85
12
    ) -> AttendeePropertyBuilder<Self, ParticipationStatusJournal> {
86
12
        AttendeePropertyBuilder::new(self, value.to_string())
87
12
    }
88

            
89
    add_categories!();
90

            
91
    add_comment!();
92

            
93
    add_contact!();
94

            
95
    add_description!();
96

            
97
    add_exception_date_times!();
98

            
99
    add_related!();
100

            
101
    add_recurrence_date!();
102

            
103
    add_request_status!();
104

            
105
    impl_other_component_properties!(
106
        XComponentPropertyBuilder,
107
        IanaComponentPropertyBuilder,
108
        JournalComponentBuilder
109
    );
110

            
111
    impl_finish_component_build!(CalendarComponent::Journal);
112
}
113

            
114
impl AddComponentProperty for JournalComponentBuilder {
115
300
    fn add_property(&mut self, property: ComponentProperty) {
116
300
        self.inner.properties.push(property);
117
300
    }
118
}