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.api.dom.java;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Set;
21  import java.util.TreeSet;
22  
23  public class Interface extends InnerInterface implements CompilationUnit {
24  
25      private final Set<FullyQualifiedJavaType> importedTypes = new TreeSet<>();
26  
27      private final Set<String> staticImports = new TreeSet<>();
28  
29      private final List<String> fileCommentLines = new ArrayList<>();
30  
31      public Interface(FullyQualifiedJavaType type) {
32          super(type);
33      }
34  
35      public Interface(String type) {
36          this(new FullyQualifiedJavaType(type));
37      }
38  
39      @Override
40      public Set<FullyQualifiedJavaType> getImportedTypes() {
41          return importedTypes;
42      }
43  
44      @Override
45      public void addImportedType(FullyQualifiedJavaType importedType) {
46          if (importedType.isExplicitlyImported()
47                  && !importedType.getPackageName().equals(getType().getPackageName())) {
48              importedTypes.add(importedType);
49          }
50      }
51  
52      @Override
53      public void addFileCommentLine(String commentLine) {
54          fileCommentLines.add(commentLine);
55      }
56  
57      @Override
58      public List<String> getFileCommentLines() {
59          return fileCommentLines;
60      }
61  
62      @Override
63      public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
64          this.importedTypes.addAll(importedTypes);
65      }
66  
67      @Override
68      public Set<String> getStaticImports() {
69          return staticImports;
70      }
71  
72      @Override
73      public void addStaticImport(String staticImport) {
74          staticImports.add(staticImport);
75      }
76  
77      @Override
78      public void addStaticImports(Set<String> staticImports) {
79          this.staticImports.addAll(staticImports);
80      }
81  
82      @Override
83      public <R> R accept(CompilationUnitVisitor<R> visitor) {
84          return visitor.visit(this);
85      }
86  }