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
use crate::io::RenderKotlin;
use crate::spec::CodeBlock;
use crate::tokens;

/// Inheritance modifiers applicable to class / file members
#[derive(Debug, Clone)]
pub enum MemberInheritanceModifier {
    /// `open` modifier
    Open,
    /// `final` modifier
    Final,
    /// `abstract` modifier
    Abstract,
}

impl RenderKotlin for MemberInheritanceModifier {
    fn render_into(&self, block: &mut CodeBlock) {
        let text = match self {
            MemberInheritanceModifier::Open => tokens::keyword::OPEN,
            MemberInheritanceModifier::Final => tokens::keyword::FINAL,
            MemberInheritanceModifier::Abstract => tokens::keyword::ABSTRACT
        };

        block.push_atom(text);
    }
}

#[cfg(test)]
mod tests {
    use crate::io::RenderKotlin;
    use crate::spec::MemberInheritanceModifier;

    #[test]
    fn test_render() {
        assert_eq!(MemberInheritanceModifier::Open.render_string(), "open");
        assert_eq!(MemberInheritanceModifier::Final.render_string(), "final");
        assert_eq!(MemberInheritanceModifier::Abstract.render_string(), "abstract");
    }
}