• 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

89.13
today-context/src/main/java/infra/context/properties/source/ConfigurationProperty.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.style.ToStringBuilder;
23
import infra.lang.Assert;
24
import infra.origin.Origin;
25
import infra.origin.OriginProvider;
26
import infra.util.ObjectUtils;
27

28
/**
29
 * A single configuration property obtained from a {@link ConfigurationPropertySource}
30
 * consisting of a {@link #getName() name}, {@link #getValue() value} and optional
31
 * {@link #getOrigin() origin}.
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
public final class ConfigurationProperty implements OriginProvider, Comparable<ConfigurationProperty> {
39

40
  private final ConfigurationPropertyName name;
41

42
  private final Object value;
43

44
  @Nullable
45
  private final ConfigurationPropertySource source;
46

47
  @Nullable
48
  private final Origin origin;
49

50
  public ConfigurationProperty(ConfigurationPropertyName name, Object value, @Nullable Origin origin) {
51
    this(null, name, value, origin);
6✔
52
  }
1✔
53

54
  private ConfigurationProperty(@Nullable ConfigurationPropertySource source,
55
          ConfigurationPropertyName name, Object value, @Nullable Origin origin) {
2✔
56
    Assert.notNull(name, "Name is required");
3✔
57
    Assert.notNull(value, "Value is required");
3✔
58
    this.source = source;
3✔
59
    this.name = name;
3✔
60
    this.value = value;
3✔
61
    this.origin = origin;
3✔
62
  }
1✔
63

64
  /**
65
   * Return the {@link ConfigurationPropertySource} that provided the property or
66
   * {@code null} if the source is unknown.
67
   *
68
   * @return the configuration property source
69
   */
70
  @Nullable
71
  public ConfigurationPropertySource getSource() {
72
    return this.source;
3✔
73
  }
74

75
  /**
76
   * Return the name of the configuration property.
77
   *
78
   * @return the configuration property name
79
   */
80
  public ConfigurationPropertyName getName() {
81
    return this.name;
3✔
82
  }
83

84
  /**
85
   * Return the value of the configuration property.
86
   *
87
   * @return the configuration property value
88
   */
89
  public Object getValue() {
90
    return this.value;
3✔
91
  }
92

93
  @Override
94
  @Nullable
95
  public Origin getOrigin() {
96
    return this.origin;
3✔
97
  }
98

99
  @Override
100
  public boolean equals(Object obj) {
101
    if (this == obj) {
3✔
102
      return true;
2✔
103
    }
104
    if (obj == null || getClass() != obj.getClass()) {
7!
105
      return false;
×
106
    }
107
    ConfigurationProperty other = (ConfigurationProperty) obj;
3✔
108
    boolean result = ObjectUtils.nullSafeEquals(this.name, other.name);
6✔
109
    result = result && ObjectUtils.nullSafeEquals(this.value, other.value);
12✔
110
    return result;
2✔
111
  }
112

113
  @Override
114
  public int hashCode() {
115
    int result = ObjectUtils.nullSafeHashCode(this.name);
4✔
116
    result = 31 * result + ObjectUtils.nullSafeHashCode(this.value);
8✔
117
    return result;
2✔
118
  }
119

120
  @Override
121
  public String toString() {
122
    return new ToStringBuilder(this)
8✔
123
            .append("name", this.name)
4✔
124
            .append("value", this.value)
4✔
125
            .append("origin", this.origin)
1✔
126
            .toString();
1✔
127
  }
128

129
  @Override
130
  public int compareTo(ConfigurationProperty other) {
131
    return this.name.compareTo(other.name);
6✔
132
  }
133

134
  @Nullable
135
  static ConfigurationProperty of(@Nullable ConfigurationPropertySource source,
136
          ConfigurationPropertyName name, @Nullable Object value, @Nullable Origin origin) {
137
    if (value == null) {
2!
138
      return null;
×
139
    }
140
    return new ConfigurationProperty(source, name, value, origin);
8✔
141
  }
142

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