• 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

91.67
today-context/src/main/java/infra/context/properties/source/ConfigurationPropertySource.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.core.env.PropertySource;
25
import infra.origin.OriginTrackedValue;
26
import infra.util.StringUtils;
27

28
/**
29
 * A source of {@link ConfigurationProperty ConfigurationProperties}.
30
 *
31
 * @author Phillip Webb
32
 * @author Madhura Bhave
33
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
34
 * @see ConfigurationPropertyName
35
 * @see OriginTrackedValue
36
 * @see #getConfigurationProperty(ConfigurationPropertyName)
37
 * @since 4.0
38
 */
39
@FunctionalInterface
40
public interface ConfigurationPropertySource {
41

42
  /**
43
   * Return a single {@link ConfigurationProperty} from the source or {@code null} if no
44
   * property can be found.
45
   *
46
   * @param name the name of the property (must not be {@code null})
47
   * @return the associated object or {@code null}.
48
   */
49
  @Nullable
50
  ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name);
51

52
  /**
53
   * Returns if the source contains any descendants of the specified name. May return
54
   * {@link ConfigurationPropertyState#PRESENT} or
55
   * {@link ConfigurationPropertyState#ABSENT} if an answer can be determined or
56
   * {@link ConfigurationPropertyState#UNKNOWN} if it's not possible to determine a
57
   * definitive answer.
58
   *
59
   * @param name the name to check
60
   * @return if the source contains any descendants
61
   */
62
  default ConfigurationPropertyState containsDescendantOf(ConfigurationPropertyName name) {
63
    return ConfigurationPropertyState.UNKNOWN;
2✔
64
  }
65

66
  /**
67
   * Return a filtered variant of this source, containing only names that match the
68
   * given {@link Predicate}.
69
   *
70
   * @param filter the filter to match
71
   * @return a filtered {@link ConfigurationPropertySource} instance
72
   */
73
  default ConfigurationPropertySource filter(Predicate<ConfigurationPropertyName> filter) {
74
    return new FilteredConfigurationPropertiesSource(this, filter);
6✔
75
  }
76

77
  /**
78
   * Return a variant of this source that supports name aliases.
79
   *
80
   * @param aliases a function that returns a stream of aliases for any given name
81
   * @return a {@link ConfigurationPropertySource} instance supporting name aliases
82
   */
83
  default ConfigurationPropertySource withAliases(ConfigurationPropertyNameAliases aliases) {
84
    return new AliasedConfigurationPropertySource(this, aliases);
6✔
85
  }
86

87
  /**
88
   * Return a variant of this source that supports a prefix.
89
   *
90
   * @param prefix the prefix for properties in the source
91
   * @return a {@link ConfigurationPropertySource} instance supporting a prefix
92
   */
93
  default ConfigurationPropertySource withPrefix(@Nullable String prefix) {
94
    return StringUtils.hasText(prefix) ? new PrefixedConfigurationPropertySource(this, prefix) : this;
11✔
95
  }
96

97
  /**
98
   * Return the underlying source that is actually providing the properties.
99
   *
100
   * @return the underlying property source or {@code null}.
101
   */
102
  @Nullable
103
  default Object getUnderlyingSource() {
104
    return null;
×
105
  }
106

107
  /**
108
   * Return a single new {@link ConfigurationPropertySource} adapted from the given
109
   * Framework {@link PropertySource} or {@code null} if the source cannot be adapted.
110
   *
111
   * @param source the Framework property source to adapt
112
   * @return an adapted source or {@code null} {@link DefaultConfigurationPropertySource}
113
   */
114
  @Nullable
115
  static ConfigurationPropertySource from(PropertySource<?> source) {
116
    if (source instanceof ConfigurationPropertySourcesPropertySource) {
3✔
117
      return null;
2✔
118
    }
119
    return DefaultConfigurationPropertySource.from(source);
3✔
120
  }
121

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