Fix ConfigurationPropertyName ancestor bug
Fix an issue with `ConfigurationPropertyName` where the `isAncesorOf` method would not work with `ConfigurationPropertyName.EMPTY` See gh-9000
This commit is contained in:
parent
10b8eb3109
commit
3153117429
|
|
@ -145,6 +145,9 @@ public final class ConfigurationPropertyName
|
|||
* @return {@code true} if this name is an ancestor
|
||||
*/
|
||||
public boolean isAncestorOf(ConfigurationPropertyName name) {
|
||||
if (this.equals(EMPTY)) {
|
||||
return true;
|
||||
}
|
||||
ConfigurationPropertyName candidate = (name == null ? null : name.getParent());
|
||||
while (candidate != null) {
|
||||
if (candidate.equals(this)) {
|
||||
|
|
|
|||
|
|
@ -274,6 +274,15 @@ public class ConfigurationPropertyNameTests {
|
|||
assertThat(grandchild.isAncestorOf(parent)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAncestorOfWhenRootReturnTrue() throws Exception {
|
||||
ConfigurationPropertyName parent = ConfigurationPropertyName.of("");
|
||||
ConfigurationPropertyName grandchild = ConfigurationPropertyName
|
||||
.of("foo.bar.baz");
|
||||
assertThat(parent.isAncestorOf(grandchild)).isTrue();
|
||||
assertThat(grandchild.isAncestorOf(parent)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendWhenNotIndexedShouldAppendWithDot() throws Exception {
|
||||
ConfigurationPropertyName name = ConfigurationPropertyName.of("foo");
|
||||
|
|
|
|||
Loading…
Reference in New Issue