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

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

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

90.0
today-context/src/main/java/infra/context/properties/source/FilteredConfigurationPropertiesSource.java
1
/*
2
 * Copyright 2017 - 2025 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.context.properties.source;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.util.function.Predicate;
23

24
import infra.lang.Assert;
25

26
/**
27
 * A filtered {@link ConfigurationPropertySource}.
28
 *
29
 * @author Phillip Webb
30
 * @author Madhura Bhave
31
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
32
 * @since 4.0
33
 */
34
class FilteredConfigurationPropertiesSource implements ConfigurationPropertySource {
35

36
  private final ConfigurationPropertySource source;
37

38
  private final Predicate<ConfigurationPropertyName> filter;
39

40
  FilteredConfigurationPropertiesSource(ConfigurationPropertySource source, Predicate<ConfigurationPropertyName> filter) {
2✔
41
    Assert.notNull(source, "Source is required");
3✔
42
    Assert.notNull(filter, "Filter is required");
3✔
43
    this.source = source;
3✔
44
    this.filter = filter;
3✔
45
  }
1✔
46

47
  @Override
48
  @Nullable
49
  public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
50
    boolean filtered = getFilter().test(name);
5✔
51
    return filtered ? getSource().getConfigurationProperty(name) : null;
9✔
52
  }
53

54
  @Override
55
  public ConfigurationPropertyState containsDescendantOf(ConfigurationPropertyName name) {
56
    ConfigurationPropertyState result = this.source.containsDescendantOf(name);
5✔
57
    if (result == ConfigurationPropertyState.PRESENT) {
3✔
58
      // We can't be sure a contained descendant won't be filtered
59
      return ConfigurationPropertyState.UNKNOWN;
2✔
60
    }
61
    return result;
2✔
62
  }
63

64
  @Override
65
  @Nullable
66
  public Object getUnderlyingSource() {
67
    return this.source.getUnderlyingSource();
×
68
  }
69

70
  protected ConfigurationPropertySource getSource() {
71
    return this.source;
3✔
72
  }
73

74
  protected Predicate<ConfigurationPropertyName> getFilter() {
75
    return this.filter;
3✔
76
  }
77

78
  @Override
79
  public String toString() {
80
    return this.source + " (filtered)";
×
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