public final class ConfigurationPropertyName extends Object implements Comparable<ConfigurationPropertyName>
a-z" "0-9") and "-", they
must be lower-case and must start with an alpha-numeric character. The "-" is
used purely for formatting, i.e. "foo-bar" and "foobar" are considered
equivalent.
The "[" and "]" characters may be used to indicate an associative
index(i.e. a Map key or a Collection index). Indexes names are not
restricted and are considered case-sensitive.
Here are some typical examples:
spring.main.banner-modeserver.hosts[0].namelog[org.springboot].levelof(CharSequence),
ConfigurationPropertySource| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigurationPropertyName.Form
The various forms that a non-indexed element value can take.
|
| Modifier and Type | Field and Description |
|---|---|
static ConfigurationPropertyName |
EMPTY
An empty
ConfigurationPropertyName. |
| Modifier and Type | Method and Description |
|---|---|
static ConfigurationPropertyName |
adapt(CharSequence name,
char separator)
Create a
ConfigurationPropertyName by adapting the given source. |
ConfigurationPropertyName |
append(ConfigurationPropertyName suffix)
Create a new
ConfigurationPropertyName by appending the given suffix. |
ConfigurationPropertyName |
append(String suffix)
Create a new
ConfigurationPropertyName by appending the given suffix. |
ConfigurationPropertyName |
chop(int size)
Return a new
ConfigurationPropertyName by chopping this name to the given
size. |
int |
compareTo(ConfigurationPropertyName other) |
boolean |
equals(Object obj) |
String |
getElement(int elementIndex,
ConfigurationPropertyName.Form form)
Return an element in the name in the given form.
|
String |
getLastElement(ConfigurationPropertyName.Form form)
Return the last element in the name in the given form.
|
int |
getNumberOfElements()
Return the total number of elements in the name.
|
ConfigurationPropertyName |
getParent()
Return the parent of this
ConfigurationPropertyName or
EMPTY if there is no parent. |
int |
hashCode() |
boolean |
hasIndexedElement()
Return
true if any element in the name is indexed. |
boolean |
isAncestorOf(ConfigurationPropertyName name)
Returns
true if this element is an ancestor (immediate or nested parent) of
the specified name. |
boolean |
isEmpty()
Returns
true if this ConfigurationPropertyName is empty. |
boolean |
isLastElementIndexed()
Return if the last element in the name is indexed.
|
boolean |
isNumericIndex(int elementIndex)
Return if the element in the name is indexed and numeric.
|
boolean |
isParentOf(ConfigurationPropertyName name)
Returns
true if this element is an immediate parent of the specified name. |
static boolean |
isValid(CharSequence name)
Returns if the given name is valid.
|
static ConfigurationPropertyName |
of(CharSequence name)
Return a
ConfigurationPropertyName for the specified string. |
static ConfigurationPropertyName |
ofIfValid(CharSequence name)
Return a
ConfigurationPropertyName for the specified string or null
if the name is not valid. |
ConfigurationPropertyName |
subName(int offset)
Return a new
ConfigurationPropertyName by based on this name offset by
specific element index. |
String |
toString() |
public static final ConfigurationPropertyName EMPTY
ConfigurationPropertyName.public boolean isEmpty()
true if this ConfigurationPropertyName is empty.true if the name is emptypublic boolean isLastElementIndexed()
true if the last element is indexedpublic boolean hasIndexedElement()
true if any element in the name is indexed.public boolean isNumericIndex(int elementIndex)
elementIndex - the index of the elementtrue if the element is indexed and numericpublic String getLastElement(ConfigurationPropertyName.Form form)
form - the form to returnpublic String getElement(int elementIndex, ConfigurationPropertyName.Form form)
elementIndex - the element indexform - the form to returnpublic int getNumberOfElements()
public ConfigurationPropertyName append(String suffix)
ConfigurationPropertyName by appending the given suffix.suffix - the elements to appendConfigurationPropertyNameInvalidConfigurationPropertyNameException - if the result is not validpublic ConfigurationPropertyName append(ConfigurationPropertyName suffix)
ConfigurationPropertyName by appending the given suffix.suffix - the elements to appendConfigurationPropertyNamepublic ConfigurationPropertyName getParent()
ConfigurationPropertyName or
EMPTY if there is no parent.public ConfigurationPropertyName chop(int size)
ConfigurationPropertyName by chopping this name to the given
size. For example, chop(1) on the name foo.bar will return
foo.size - the size to choppublic ConfigurationPropertyName subName(int offset)
ConfigurationPropertyName by based on this name offset by
specific element index. For example, chop(1) on the name foo.bar
will return bar.offset - the element offsetpublic boolean isParentOf(ConfigurationPropertyName name)
true if this element is an immediate parent of the specified name.name - the name to checktrue if this name is an ancestorpublic boolean isAncestorOf(ConfigurationPropertyName name)
true if this element is an ancestor (immediate or nested parent) of
the specified name.name - the name to checktrue if this name is an ancestorpublic int compareTo(ConfigurationPropertyName other)
compareTo in interface Comparable<ConfigurationPropertyName>public static boolean isValid(CharSequence name)
true then the
name may be used with of(CharSequence) without throwing an exception.name - the name to testtrue if the name is validpublic static ConfigurationPropertyName of(CharSequence name)
ConfigurationPropertyName for the specified string.name - the source nameConfigurationPropertyName instanceInvalidConfigurationPropertyNameException - if the name is not validpublic static ConfigurationPropertyName ofIfValid(CharSequence name)
ConfigurationPropertyName for the specified string or null
if the name is not valid.name - the source nameConfigurationPropertyName instancepublic static ConfigurationPropertyName adapt(CharSequence name, char separator)
ConfigurationPropertyName by adapting the given source. See
adapt(CharSequence, char, Function) for details.name - the name to parseseparator - the separator used to split the nameConfigurationPropertyName