kotlin_poet_rs/spec/
class_inheritance_modifier.rs1use crate::io::RenderKotlin;
2use crate::spec::CodeBlock;
3use crate::tokens;
4
5#[derive(Debug, Clone, Default)]
11pub enum ClassInheritanceModifier {
12 Open,
14 #[default]
16 Final,
17 Interface,
19 Abstract,
21 Sealed,
23 Object,
25 Enum,
27 Data,
29}
30
31impl RenderKotlin for ClassInheritanceModifier {
32 fn render_into(&self, block: &mut CodeBlock) {
33 let text = match self {
34 ClassInheritanceModifier::Open => tokens::keyword::OPEN,
35 ClassInheritanceModifier::Final => tokens::keyword::FINAL,
36 ClassInheritanceModifier::Abstract => tokens::keyword::ABSTRACT,
37 ClassInheritanceModifier::Sealed => tokens::keyword::SEALED,
38 ClassInheritanceModifier::Interface => tokens::keyword::INTERFACE,
39 ClassInheritanceModifier::Object => tokens::keyword::OBJECT,
40 ClassInheritanceModifier::Enum => tokens::keyword::ENUM,
41 ClassInheritanceModifier::Data => tokens::keyword::DATA
42 };
43
44 block.push_atom(text);
45 }
46}
47
48#[cfg(test)]
49mod tests {
50 use crate::io::RenderKotlin;
51 use crate::spec::ClassInheritanceModifier;
52
53 #[test]
54 fn test_render() {
55 assert_eq!(ClassInheritanceModifier::Open.render_string(), "open");
56 assert_eq!(ClassInheritanceModifier::Final.render_string(), "final");
57 assert_eq!(ClassInheritanceModifier::Abstract.render_string(), "abstract");
58 assert_eq!(ClassInheritanceModifier::Sealed.render_string(), "sealed");
59 }
60}