public final class ConfigurationPropertyName extends java.lang.Object implements java.lang.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-mode
server.hosts[0].name
log[org.springboot].level
of(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(java.lang.CharSequence name,
char separator)
Create a
ConfigurationPropertyName by adapting the given source. |
ConfigurationPropertyName |
append(java.lang.String elements)
Create a new
ConfigurationPropertyName by appending the given elements. |
ConfigurationPropertyName |
chop(int size)
Return a new
ConfigurationPropertyName by chopping this name to the given
size . |
int |
compareTo(ConfigurationPropertyName other) |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getElement(int elementIndex,
ConfigurationPropertyName.Form form)
Return an element in the name in the given form.
|
java.lang.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 |
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(java.lang.CharSequence name)
Returns if the given name is valid.
|
static ConfigurationPropertyName |
of(java.lang.CharSequence name)
Return a
ConfigurationPropertyName for the specified string. |
static ConfigurationPropertyName |
ofIfValid(java.lang.CharSequence name)
Return a
ConfigurationPropertyName for the specified string or null
if the name is not valid. |
java.lang.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 isNumericIndex(int elementIndex)
elementIndex
- the index of the elementtrue
if the element is indexed and numericpublic java.lang.String getLastElement(ConfigurationPropertyName.Form form)
form
- the form to returnpublic java.lang.String getElement(int elementIndex, ConfigurationPropertyName.Form form)
elementIndex
- the element indexform
- the form to returnpublic int getNumberOfElements()
public ConfigurationPropertyName append(java.lang.String elements)
ConfigurationPropertyName
by appending the given elements.elements
- the elements to appendConfigurationPropertyName
InvalidConfigurationPropertyNameException
- if the result is not validpublic 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 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 java.lang.Comparable<ConfigurationPropertyName>
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static boolean isValid(java.lang.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(java.lang.CharSequence name)
ConfigurationPropertyName
for the specified string.name
- the source nameConfigurationPropertyName
instanceInvalidConfigurationPropertyNameException
- if the name is not validpublic static ConfigurationPropertyName ofIfValid(java.lang.CharSequence name)
ConfigurationPropertyName
for the specified string or null
if the name is not valid.name
- the source nameConfigurationPropertyName
instancepublic static ConfigurationPropertyName adapt(java.lang.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