• 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

92.59
today-context/src/main/java/infra/context/properties/source/ConfigurationPropertySourcesPropertySource.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 infra.core.env.Environment;
23
import infra.core.env.PropertyResolver;
24
import infra.core.env.PropertySource;
25
import infra.origin.Origin;
26
import infra.origin.OriginLookup;
27

28
/**
29
 * {@link PropertySource} that exposes {@link ConfigurationPropertySource} instances so
30
 * that they can be used with a {@link PropertyResolver} or added to the
31
 * {@link Environment}.
32
 *
33
 * @author Phillip Webb
34
 * @author Madhura Bhave
35
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
36
 * @since 4.0
37
 */
38
class ConfigurationPropertySourcesPropertySource extends PropertySource<Iterable<ConfigurationPropertySource>>
39
        implements OriginLookup<String> {
40

41
  ConfigurationPropertySourcesPropertySource(String name, Iterable<ConfigurationPropertySource> source) {
42
    super(name, source);
4✔
43
  }
1✔
44

45
  @Override
46
  public boolean containsProperty(String name) {
47
    return findConfigurationProperty(name) != null;
8✔
48
  }
49

50
  @Override
51
  @Nullable
52
  public Object getProperty(String name) {
53
    ConfigurationProperty configurationProperty = findConfigurationProperty(name);
4✔
54
    return configurationProperty != null ? configurationProperty.getValue() : null;
7✔
55
  }
56

57
  @Nullable
58
  @Override
59
  public Origin getOrigin(String name) {
60
    return Origin.from(findConfigurationProperty(name));
5✔
61
  }
62

63
  @Nullable
64
  private ConfigurationProperty findConfigurationProperty(String name) {
65
    try {
66
      return findConfigurationProperty(ConfigurationPropertyName.of(name, true));
6✔
67
    }
68
    catch (Exception ex) {
×
69
      return null;
×
70
    }
71
  }
72

73
  @Nullable
74
  ConfigurationProperty findConfigurationProperty(@Nullable ConfigurationPropertyName name) {
75
    if (name == null) {
2✔
76
      return null;
2✔
77
    }
78
    for (ConfigurationPropertySource configurationPropertySource : getSource()) {
12✔
79
      ConfigurationProperty configurationProperty = configurationPropertySource.getConfigurationProperty(name);
4✔
80
      if (configurationProperty != null) {
2✔
81
        return configurationProperty;
2✔
82
      }
83
    }
1✔
84
    return null;
2✔
85
  }
86

87
}
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