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

mybatis / generator / 1942

12 Jan 2026 05:01PM UTC coverage: 88.75% (+0.4%) from 88.365%
1942

push

github

web-flow
Merge pull request #1412 from jeffgbutler/jspecify

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

68.0
/core/mybatis-generator-core/src/main/java/org/mybatis/generator/config/Configuration.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.config;
17

18
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
19
import static org.mybatis.generator.internal.util.messages.Messages.getString;
20

21
import java.util.ArrayList;
22
import java.util.List;
23

24
import org.jspecify.annotations.Nullable;
25
import org.mybatis.generator.exception.InvalidConfigurationException;
26

27
public class Configuration {
28
    private final List<Context> contexts;
29
    private final List<String> classPathEntries;
30

31
    public Configuration() {
1✔
32
        contexts = new ArrayList<>();
1✔
33
        classPathEntries = new ArrayList<>();
1✔
34
    }
1✔
35

36
    public void addClasspathEntry(@Nullable String entry) {
NEW
37
        if (entry != null) {
×
NEW
38
            classPathEntries.add(entry);
×
39
        }
UNCOV
40
    }
×
41

42
    public List<String> getClassPathEntries() {
43
        return classPathEntries;
1✔
44
    }
45

46
    /**
47
     * This method does a simple validate, it makes sure that all required fields have been filled in and that all
48
     * implementation classes exist and are of the proper type. It does not do any more complex operations such as:
49
     * validating that database tables exist or validating that named columns exist
50
     *
51
     * @throws InvalidConfigurationException
52
     *             the invalid configuration exception
53
     */
54
    public void validate() throws InvalidConfigurationException {
55
        List<String> errors = new ArrayList<>();
1✔
56

57
        for (String classPathEntry : classPathEntries) {
1!
58
            if (!stringHasValue(classPathEntry)) {
×
59
                errors.add(getString("ValidationError.19")); //$NON-NLS-1$
×
60
                // only need to state this error once
61
                break;
×
62
            }
63
        }
×
64

65
        if (contexts.isEmpty()) {
1!
66
            errors.add(getString("ValidationError.11")); //$NON-NLS-1$
×
67
        } else {
68
            for (Context context : contexts) {
1✔
69
                context.validate(errors);
1✔
70
            }
1✔
71
        }
72

73
        if (!errors.isEmpty()) {
1✔
74
            throw new InvalidConfigurationException(errors);
1✔
75
        }
76
    }
1✔
77

78
    public List<Context> getContexts() {
79
        return contexts;
1✔
80
    }
81

82
    public void addContext(Context context) {
83
        contexts.add(context);
1✔
84
    }
1✔
85
}
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