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 IanaComponent {
13
    pub(crate) name: String,
14
    pub(crate) properties: Vec<ComponentProperty>,
15
}
16

            
17
impl_component_access!(IanaComponent);
18

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

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

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

            
38
pub struct IanaComponentBuilder {
39
    owner: ICalObjectBuilder,
40
    inner: IanaComponent,
41
}
42

            
43
impl IanaComponentBuilder {
44
14
    pub(crate) fn new(owner: ICalObjectBuilder, name: String) -> IanaComponentBuilder {
45
14
        IanaComponentBuilder {
46
14
            owner,
47
14
            inner: IanaComponent {
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
        IanaComponentBuilder
58
    );
59

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