1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.runtime.dynamic.sql.elements;
17
18 import java.util.HashSet;
19 import java.util.Set;
20
21 import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
22 import org.mybatis.generator.api.dom.java.Method;
23
24 public class MethodAndImports {
25
26 private final Method method;
27 private final Set<FullyQualifiedJavaType> imports;
28 private final Set<String> staticImports;
29
30 private MethodAndImports(Builder builder) {
31 method = builder.method;
32 imports = builder.imports;
33 staticImports = builder.staticImports;
34 }
35
36 public Method getMethod() {
37 return method;
38 }
39
40 public Set<FullyQualifiedJavaType> getImports() {
41 return imports;
42 }
43
44 public Set<String> getStaticImports() {
45 return staticImports;
46 }
47
48 public static Builder withMethod(Method method) {
49 return new Builder().withMethod(method);
50 }
51
52 public static class Builder {
53 private Method method;
54 private final Set<FullyQualifiedJavaType> imports = new HashSet<>();
55 private final Set<String> staticImports = new HashSet<>();
56
57 public Builder withMethod(Method method) {
58 this.method = method;
59 return this;
60 }
61
62 public Builder withImport(FullyQualifiedJavaType importedType) {
63 this.imports.add(importedType);
64 return this;
65 }
66
67 public Builder withImports(Set<FullyQualifiedJavaType> imports) {
68 this.imports.addAll(imports);
69 return this;
70 }
71
72 public Builder withStaticImport(String staticImport) {
73 this.staticImports.add(staticImport);
74 return this;
75 }
76
77 public Builder withStaticImports(Set<String> staticImports) {
78 this.staticImports.addAll(staticImports);
79 return this;
80 }
81
82 public MethodAndImports build() {
83 return new MethodAndImports(this);
84 }
85 }
86 }