• 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

95.65
/core/mybatis-generator-core/src/main/java/org/mybatis/generator/config/IgnoredColumnPattern.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.Objects;
24
import java.util.regex.Pattern;
25

26
import org.jspecify.annotations.Nullable;
27

28
public class IgnoredColumnPattern {
29

30
    private final String patternRegex;
31
    private final Pattern pattern;
32
    private final List<IgnoredColumnException> exceptions;
33

34
    protected IgnoredColumnPattern(Builder builder) {
1✔
35
        this.patternRegex = Objects.requireNonNull(builder.pattern);
1✔
36
        pattern = Pattern.compile(patternRegex);
1✔
37
        exceptions = builder.exceptions;
1✔
38
    }
1✔
39

40
    public boolean matches(String columnName) {
41
        boolean matches = pattern.matcher(columnName).matches();
1✔
42

43
        if (matches) {
1!
44
            for (IgnoredColumnException exception : exceptions) {
1✔
45
                if (exception.matches(columnName)) {
1✔
46
                    matches = false;
1✔
47
                    break;
1✔
48
                }
49
            }
1✔
50
        }
51

52
        return matches;
1✔
53
    }
54

55
    public void validate(List<String> errors, String tableName) {
56
        if (!stringHasValue(patternRegex)) {
1!
NEW
57
            errors.add(getString("ValidationError.27", tableName)); //$NON-NLS-1$
×
58
        }
59
    }
1✔
60

61
    public static class Builder {
1✔
62
        private @Nullable String pattern;
63
        private final List<IgnoredColumnException> exceptions = new ArrayList<>();
1✔
64

65
        public Builder withPattern(@Nullable String pattern) {
66
            this.pattern = pattern;
1✔
67
            return this;
1✔
68
        }
69

70
        @SuppressWarnings("UnusedReturnValue")
71
        public Builder addException(IgnoredColumnException exception) {
72
            exceptions.add(exception);
1✔
73
            return this;
1✔
74
        }
75

76
        public IgnoredColumnPattern build() {
77
            return new IgnoredColumnPattern(this);
1✔
78
        }
79
    }
80
}
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