1
use crate::model::component::{
2
    impl_finish_component_build, impl_other_component_properties, CalendarComponent,
3
};
4
use crate::model::impl_component_access;
5
use crate::model::object::ICalObjectBuilder;
6
use crate::model::property::{
7
    AddComponentProperty, ComponentProperty, IanaComponentPropertyBuilder,
8
    XComponentPropertyBuilder,
9
};
10

            
11
#[derive(Debug, PartialEq)]
12
pub struct XComponent {
13
    pub(crate) name: String,
14
    pub(crate) properties: Vec<ComponentProperty>,
15
}
16

            
17
impl_component_access!(XComponent);
18

            
19
impl XComponent {
20
42
    pub(crate) fn new(name: String) -> Self {
21
42
        XComponent {
22
42
            name,
23
42
            properties: Vec::new(),
24
42
        }
25
42
    }
26

            
27
    pub fn name(&self) -> &str {
28
        &self.name
29
    }
30
}
31

            
32
impl AddComponentProperty for XComponentBuilder {
33
26
    fn add_property(&mut self, property: ComponentProperty) {
34
26
        self.inner.properties.push(property);
35
26
    }
36
}
37

            
38
pub struct XComponentBuilder {
39
    owner: ICalObjectBuilder,
40
    inner: XComponent,
41
}
42

            
43
impl XComponentBuilder {
44
14
    pub(crate) fn new(owner: ICalObjectBuilder, name: String) -> XComponentBuilder {
45
14
        XComponentBuilder {
46
14
            owner,
47
14
            inner: XComponent {
48
14
                name,
49
14
                properties: Vec::new(),
50
14
            },
51
14
        }
52
14
    }
53

            
54
    impl_other_component_properties!(
55
        XComponentPropertyBuilder,
56
        IanaComponentPropertyBuilder,
57
        XComponentBuilder
58
    );
59

            
60
    impl_finish_component_build!(CalendarComponent::XComponent);
61
}