• 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

81.25
today-context/src/main/java/infra/context/properties/bind/BindException.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.bind;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.io.Serial;
23

24
import infra.context.properties.source.ConfigurationProperty;
25
import infra.context.properties.source.ConfigurationPropertyName;
26
import infra.origin.Origin;
27
import infra.origin.OriginProvider;
28

29
/**
30
 * Exception thrown when binding fails.
31
 *
32
 * @author Phillip Webb
33
 * @author Madhura Bhave
34
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
35
 * @since 4.0
36
 */
37
public class BindException extends RuntimeException implements OriginProvider {
38

39
  @Serial
40
  private static final long serialVersionUID = 1L;
41

42
  private final Bindable<?> target;
43

44
  @Nullable
45
  private final ConfigurationProperty property;
46

47
  private final ConfigurationPropertyName name;
48

49
  BindException(ConfigurationPropertyName name, Bindable<?> target, @Nullable ConfigurationProperty property, Throwable cause) {
50
    super(buildMessage(name, target), cause);
6✔
51
    this.name = name;
3✔
52
    this.target = target;
3✔
53
    this.property = property;
3✔
54
  }
1✔
55

56
  /**
57
   * Return the name of the configuration property being bound.
58
   *
59
   * @return the configuration property name
60
   */
61
  public ConfigurationPropertyName getName() {
62
    return this.name;
×
63
  }
64

65
  /**
66
   * Return the target being bound.
67
   *
68
   * @return the bind target
69
   */
70
  public Bindable<?> getTarget() {
71
    return this.target;
3✔
72
  }
73

74
  /**
75
   * Return the configuration property name of the item that was being bound.
76
   *
77
   * @return the configuration property name
78
   */
79
  @Nullable
80
  public ConfigurationProperty getProperty() {
81
    return this.property;
3✔
82
  }
83

84
  @Nullable
85
  @Override
86
  public Origin getOrigin() {
87
    return Origin.from(this.name);
×
88
  }
89

90
  private static String buildMessage(@Nullable ConfigurationPropertyName name, Bindable<?> target) {
91
    StringBuilder message = new StringBuilder();
4✔
92
    message.append("Failed to bind properties");
4✔
93
    message.append((name != null) ? " under '" + name + "'" : "");
9!
94
    message.append(" to ").append(target.getType());
7✔
95
    return message.toString();
3✔
96
  }
97

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