commit
74d69d0eb1
|
|
@ -773,7 +773,7 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
|
||||||
ElementType[] type = new ElementType[size];
|
ElementType[] type = new ElementType[size];
|
||||||
System.arraycopy(this.type, 0, type, 0, this.size);
|
System.arraycopy(this.type, 0, type, 0, this.size);
|
||||||
System.arraycopy(additional.type, 0, type, this.size, additional.size);
|
System.arraycopy(additional.type, 0, type, this.size, additional.size);
|
||||||
CharSequence[] resolved = newResolved(size);
|
CharSequence[] resolved = newResolved(0, size);
|
||||||
for (int i = 0; i < additional.size; i++) {
|
for (int i = 0; i < additional.size; i++) {
|
||||||
resolved[this.size + i] = additional.get(i);
|
resolved[this.size + i] = additional.get(i);
|
||||||
}
|
}
|
||||||
|
|
@ -781,13 +781,13 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
Elements chop(int size) {
|
Elements chop(int size) {
|
||||||
CharSequence[] resolved = newResolved(size);
|
CharSequence[] resolved = newResolved(0, size);
|
||||||
return new Elements(this.source, size, this.start, this.end, this.type, resolved);
|
return new Elements(this.source, size, this.start, this.end, this.type, resolved);
|
||||||
}
|
}
|
||||||
|
|
||||||
Elements subElements(int offset) {
|
Elements subElements(int offset) {
|
||||||
int size = this.size - offset;
|
int size = this.size - offset;
|
||||||
CharSequence[] resolved = newResolved(size);
|
CharSequence[] resolved = newResolved(offset, size);
|
||||||
int[] start = new int[size];
|
int[] start = new int[size];
|
||||||
System.arraycopy(this.start, offset, start, 0, size);
|
System.arraycopy(this.start, offset, start, 0, size);
|
||||||
int[] end = new int[size];
|
int[] end = new int[size];
|
||||||
|
|
@ -797,10 +797,10 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
|
||||||
return new Elements(this.source, size, start, end, type, resolved);
|
return new Elements(this.source, size, start, end, type, resolved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence[] newResolved(int size) {
|
private CharSequence[] newResolved(int offset, int size) {
|
||||||
CharSequence[] resolved = new CharSequence[size];
|
CharSequence[] resolved = new CharSequence[size];
|
||||||
if (this.resolved != null) {
|
if (this.resolved != null) {
|
||||||
System.arraycopy(this.resolved, 0, resolved, 0, Math.min(size, this.size));
|
System.arraycopy(this.resolved, offset, resolved, 0, Math.min(size, this.size));
|
||||||
}
|
}
|
||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.context.properties.source;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
@ -492,6 +493,21 @@ class ConfigurationPropertyNameTests {
|
||||||
assertThat(name.subName(2)).hasToString("baz");
|
assertThat(name.subName(2)).hasToString("baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void subNameOfAdaptedNameWhenOffsetLessThanSizeShouldReturnSubName() {
|
||||||
|
ConfigurationPropertyName name = ConfigurationPropertyName.adapt("MY_LOGGING_LEVEL_ONE", '_');
|
||||||
|
assertThat(name.subName(1)).hasToString("logging.level.one");
|
||||||
|
assertThat(name.subName(2)).hasToString("level.one");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void subNameOfAdaptedNameWithValueProcessorWhenOffsetLessThanSizeShouldReturnSubName() {
|
||||||
|
ConfigurationPropertyName name = ConfigurationPropertyName.adapt("MY_LOGGING_LEVEL_ONE", '_',
|
||||||
|
(value) -> value.toString().toLowerCase(Locale.ENGLISH));
|
||||||
|
assertThat(name.subName(1)).hasToString("logging.level.one");
|
||||||
|
assertThat(name.subName(2)).hasToString("level.one");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void subNameWhenOffsetZeroShouldReturnName() {
|
void subNameWhenOffsetZeroShouldReturnName() {
|
||||||
ConfigurationPropertyName name = ConfigurationPropertyName.of("foo.bar.baz");
|
ConfigurationPropertyName name = ConfigurationPropertyName.of("foo.bar.baz");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue