1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.api.dom.kotlin;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public abstract class KotlinNamedItem {
22 private final String name;
23 private final List<KotlinModifier> modifiers = new ArrayList<>();
24 private final List<String> annotations = new ArrayList<>();
25
26 protected KotlinNamedItem(AbstractBuilder<?> builder) {
27 name = builder.name;
28 modifiers.addAll(builder.modifiers);
29 annotations.addAll(builder.annotations);
30 }
31
32 public String getName() {
33 return name;
34 }
35
36 public List<KotlinModifier> getModifiers() {
37 return modifiers;
38 }
39
40 public void addAnnotation(String annotation) {
41 annotations.add(annotation);
42 }
43
44 public List<String> getAnnotations() {
45 return annotations;
46 }
47
48 public abstract <R> R accept(KotlinNamedItemVisitor<R> visitor);
49
50 public abstract static class AbstractBuilder<T extends AbstractBuilder<T>> {
51 private final String name;
52 private final List<KotlinModifier> modifiers = new ArrayList<>();
53 private final List<String> annotations = new ArrayList<>();
54
55 protected AbstractBuilder(String name) {
56 this.name = name;
57 }
58
59 public T withModifier(KotlinModifier modifier) {
60 modifiers.add(modifier);
61 return getThis();
62 }
63
64 public T withAnnotation(String annotation) {
65 annotations.add(annotation);
66 return getThis();
67 }
68
69 protected abstract T getThis();
70 }
71 }