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

TAKETODAY / today-infrastructure / 15794111114

21 Jun 2025 08:54AM UTC coverage: 81.755% (+0.008%) from 81.747%
15794111114

Pull #286

github

web-flow
Merge e7915e795 into 8470e463d
Pull Request #286: 开发分支

59270 of 77451 branches covered (76.53%)

Branch coverage included in aggregate %.

140365 of 166736 relevant lines covered (84.18%)

3.6 hits per line

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

72.73
today-context/src/main/java/infra/validation/beanvalidation/FilteredMethodValidationPostProcessor.java
1
/*
2
 * Copyright 2017 - 2024 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.validation.beanvalidation;
19

20
import java.io.Serial;
21
import java.util.ArrayList;
22
import java.util.Collection;
23
import java.util.stream.Stream;
24

25
import infra.aop.support.ComposablePointcut;
26
import infra.aop.support.DefaultPointcutAdvisor;
27

28
/**
29
 * Custom {@link MethodValidationPostProcessor} that applies
30
 * {@link MethodValidationExcludeFilter exclusion filters}.
31
 *
32
 * @author Andy Wilkinson
33
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
34
 * @since 4.0
35
 */
36
public class FilteredMethodValidationPostProcessor extends MethodValidationPostProcessor {
37

38
  @Serial
39
  private static final long serialVersionUID = 1L;
40

41
  private final Collection<MethodValidationExcludeFilter> excludeFilters;
42

43
  /**
44
   * Creates a new {@code FilteredMethodValidationPostProcessor} that will apply the
45
   * given {@code excludeFilters} when identifying beans that are eligible for method
46
   * validation post-processing.
47
   *
48
   * @param excludeFilters filters to apply
49
   */
50
  public FilteredMethodValidationPostProcessor(Stream<MethodValidationExcludeFilter> excludeFilters) {
×
51
    this.excludeFilters = excludeFilters.toList();
×
52
  }
×
53

54
  /**
55
   * Creates a new {@code FilteredMethodValidationPostProcessor} that will apply the
56
   * given {@code excludeFilters} when identifying beans that are eligible for method
57
   * validation post-processing.
58
   *
59
   * @param excludeFilters filters to apply
60
   */
61
  public FilteredMethodValidationPostProcessor(Collection<MethodValidationExcludeFilter> excludeFilters) {
2✔
62
    this.excludeFilters = new ArrayList<>(excludeFilters);
6✔
63
  }
1✔
64

65
  @Override
66
  public void afterPropertiesSet() {
67
    super.afterPropertiesSet();
2✔
68
    if (advisor instanceof DefaultPointcutAdvisor advisor) {
9!
69
      advisor.setPointcut(new ComposablePointcut(advisor.getPointcut())
9✔
70
              .intersection(this::isIncluded));
1✔
71
    }
72
  }
1✔
73

74
  private boolean isIncluded(Class<?> candidate) {
75
    for (MethodValidationExcludeFilter exclusionFilter : this.excludeFilters) {
11✔
76
      if (exclusionFilter.isExcluded(candidate)) {
4!
77
        return false;
2✔
78
      }
79
    }
×
80
    return true;
2✔
81
  }
82

83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc