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

mybatis / generator / 2202

05 May 2026 07:27PM UTC coverage: 91.746% (+0.04%) from 91.703%
2202

push

github

web-flow
Merge pull request #1508 from mybatis/renovate/com.github.javaparser-javaparser-core-3.x

Update dependency com.github.javaparser:javaparser-core to v3.28.1

2454 of 3154 branches covered (77.81%)

12038 of 13121 relevant lines covered (91.75%)

0.92 hits per line

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

75.76
/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
import java.util.Optional;
24

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

28
public class Configuration {
29
    private final List<Context> contexts;
30
    private final List<String> classPathEntries;
31
    private final @Nullable IndentationConfiguration indentationConfiguration;
32

33
    private Configuration(Builder builder) {
1✔
34
        contexts = builder.contexts;
1✔
35
        classPathEntries = builder.classPathEntries;
1✔
36
        indentationConfiguration = builder.indentationConfiguration;
1✔
37
    }
1✔
38

39
    public List<String> getClassPathEntries() {
40
        return classPathEntries;
1✔
41
    }
42

43
    public List<Context> getContexts() {
44
        return contexts;
1✔
45
    }
46

47
    public Optional<IndentationConfiguration> getIndentationConfiguration() {
48
        return Optional.ofNullable(indentationConfiguration);
1✔
49
    }
50

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

62
        for (String classPathEntry : classPathEntries) {
1!
63
            if (!stringHasValue(classPathEntry)) {
×
64
                errors.add(getString("ValidationError.19")); //$NON-NLS-1$
×
65
                // only need to state this error once
66
                break;
×
67
            }
68
        }
×
69

70
        if (contexts.isEmpty()) {
1!
71
            errors.add(getString("ValidationError.11")); //$NON-NLS-1$
×
72
        } else {
73
            for (Context context : contexts) {
1✔
74
                context.validate(errors);
1✔
75
            }
1✔
76
        }
77

78
        if (!errors.isEmpty()) {
1✔
79
            throw new InvalidConfigurationException(getString("ValidationError.32"), errors); //$NON-NLS-1$
1✔
80
        }
81
    }
1✔
82

83
    public static class Builder {
1✔
84
        private final List<Context> contexts = new ArrayList<>();
1✔
85
        private final List<String> classPathEntries = new ArrayList<>();
1✔
86
        private @Nullable IndentationConfiguration indentationConfiguration;
87

88
        public Builder withContext(Context context) {
89
            contexts.add(context);
1✔
90
            return this;
1✔
91
        }
92

93
        public Builder withClassPathEntry(@Nullable  String classPathEntry) {
94
            if (classPathEntry != null) {
×
95
                classPathEntries.add(classPathEntry);
×
96
            }
97
            return this;
×
98
        }
99

100
        public Builder withIndentationConfiguration(IndentationConfiguration indentationConfiguration) {
101
            this.indentationConfiguration = indentationConfiguration;
1✔
102
            return this;
1✔
103
        }
104

105
        public Configuration build() {
106
            return new Configuration(this);
1✔
107
        }
108
    }
109
}
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