• 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

93.88
today-context/src/main/java/infra/context/properties/source/AliasedConfigurationPropertySource.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.lang.Assert;
23

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

35
  public final ConfigurationPropertySource source;
36

37
  public final ConfigurationPropertyNameAliases aliases;
38

39
  AliasedConfigurationPropertySource(ConfigurationPropertySource source, ConfigurationPropertyNameAliases aliases) {
2✔
40
    Assert.notNull(source, "Source is required");
3✔
41
    Assert.notNull(aliases, "Aliases is required");
3✔
42
    this.source = source;
3✔
43
    this.aliases = aliases;
3✔
44
  }
1✔
45

46
  @Override
47
  @Nullable
48
  public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
49
    Assert.notNull(name, "Name is required");
3✔
50
    ConfigurationProperty result = source.getConfigurationProperty(name);
5✔
51
    if (result == null) {
2✔
52
      ConfigurationPropertyName aliasedName = aliases.getNameForAlias(name);
5✔
53
      result = aliasedName != null ? source.getConfigurationProperty(aliasedName) : null;
8!
54
    }
55
    return result;
2✔
56
  }
57

58
  @Override
59
  public ConfigurationPropertyState containsDescendantOf(ConfigurationPropertyName name) {
60
    Assert.notNull(name, "Name is required");
3✔
61
    ConfigurationPropertyState result = this.source.containsDescendantOf(name);
5✔
62
    if (result != ConfigurationPropertyState.ABSENT) {
3✔
63
      return result;
2✔
64
    }
65
    for (ConfigurationPropertyName alias : aliases.getAliases(name)) {
13✔
66
      ConfigurationPropertyState aliasResult = this.source.containsDescendantOf(alias);
5✔
67
      if (aliasResult != ConfigurationPropertyState.ABSENT) {
3✔
68
        return aliasResult;
2✔
69
      }
70
    }
1✔
71
    for (ConfigurationPropertyName from : aliases) {
11✔
72
      for (ConfigurationPropertyName alias : aliases.getAliases(from)) {
13✔
73
        if (name.isAncestorOf(alias)) {
4✔
74
          if (this.source.getConfigurationProperty(from) != null) {
5!
75
            return ConfigurationPropertyState.PRESENT;
2✔
76
          }
77
        }
78
      }
1✔
79
    }
1✔
80
    return ConfigurationPropertyState.ABSENT;
2✔
81
  }
82

83
  @Nullable
84
  @Override
85
  public Object getUnderlyingSource() {
86
    return this.source.getUnderlyingSource();
×
87
  }
88

89
  protected ConfigurationPropertySource getSource() {
90
    return this.source;
3✔
91
  }
92

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