View Javadoc
1   /*
2    *    Copyright 2006-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.runtime.kotlin.elements;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import org.mybatis.generator.api.dom.kotlin.KotlinFunction;
22  
23  public class KotlinFunctionAndImports {
24  
25      private final KotlinFunction function;
26      private final Set<String> imports;
27  
28      private KotlinFunctionAndImports(Builder builder) {
29          function = builder.function;
30          imports = builder.imports;
31      }
32  
33      public KotlinFunction getFunction() {
34          return function;
35      }
36  
37      public Set<String> getImports() {
38          return imports;
39      }
40  
41      public static Builder withFunction(KotlinFunction function) {
42          return new Builder().withFunction(function);
43      }
44  
45      public static class Builder {
46          private KotlinFunction function;
47          private final Set<String> imports = new HashSet<>();
48  
49          public Builder withFunction(KotlinFunction function) {
50              this.function = function;
51              return this;
52          }
53  
54          public Builder withImport(String im) {
55              this.imports.add(im);
56              return this;
57          }
58  
59          public Builder withImports(Set<String> imports) {
60              this.imports.addAll(imports);
61              return this;
62          }
63  
64          public KotlinFunctionAndImports build() {
65              return new KotlinFunctionAndImports(this);
66          }
67      }
68  }