• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / generator / 1941

12 Jan 2026 04:39PM UTC coverage: 88.75% (+0.4%) from 88.365%
1941

Pull #1412

github

web-flow
Merge b9b8be318 into 98a4124a3
Pull Request #1412: Adopt JSpecify

2331 of 3162 branches covered (73.72%)

1800 of 1949 new or added lines in 202 files covered. (92.36%)

18 existing lines in 10 files now uncovered.

11384 of 12827 relevant lines covered (88.75%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/GeneratedJavaFile.java
1
/*
2
 *    Copyright 2006-2026 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;
17

18
import java.util.Optional;
19

20
import org.jspecify.annotations.Nullable;
21
import org.mybatis.generator.api.dom.java.CompilationUnit;
22

23
public class GeneratedJavaFile extends GeneratedFile {
24

25
    private final CompilationUnit compilationUnit;
26

27
    private final @Nullable String fileEncoding;
28

29
    private final JavaFormatter javaFormatter;
30

31
    public GeneratedJavaFile(CompilationUnit compilationUnit,
32
            String targetProject,
33
            @Nullable String fileEncoding,
34
            JavaFormatter javaFormatter) {
35
        super(targetProject);
1✔
36
        this.compilationUnit = compilationUnit;
1✔
37
        this.fileEncoding = fileEncoding;
1✔
38
        this.javaFormatter = javaFormatter;
1✔
39
    }
1✔
40

41
    public GeneratedJavaFile(CompilationUnit compilationUnit,
42
            String targetProject,
43
            JavaFormatter javaFormatter) {
44
        this(compilationUnit, targetProject, null, javaFormatter);
1✔
45
    }
1✔
46

47
    @Override
48
    public String getFormattedContent() {
49
        return javaFormatter.getFormattedContent(compilationUnit);
×
50
    }
51

52
    @Override
53
    public String getFileName() {
54
        return compilationUnit.getType().getShortNameWithoutTypeArguments() + ".java"; //$NON-NLS-1$
1✔
55
    }
56

57
    @Override
58
    public String getTargetPackage() {
59
        return compilationUnit.getType().getPackageName();
1✔
60
    }
61

62
    /**
63
     * This method is required by the Eclipse Java merger. If you are not
64
     * running in Eclipse, or some other system that implements the Java merge
65
     * function, you may return null from this method.
66
     *
67
     * @return the CompilationUnit associated with this file, or null if the
68
     *         file is not mergeable.
69
     */
70
    public CompilationUnit getCompilationUnit() {
71
        return compilationUnit;
1✔
72
    }
73

74
    /**
75
     * A Java file is mergeable if the getCompilationUnit() method returns a valid compilation unit.
76
     *
77
     * @return true, if is mergeable
78
     */
79
    @Override
80
    public boolean isMergeable() {
81
        return true;
×
82
    }
83

84
    @Override
85
    public Optional<String> getFileEncoding() {
NEW
86
        return Optional.ofNullable(fileEncoding);
×
87
    }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc