Class ConfigurationPropertyName
java.lang.Object
org.springframework.boot.context.properties.source.ConfigurationPropertyName
- All Implemented Interfaces:
- Comparable<ConfigurationPropertyName>
public final class ConfigurationPropertyName
extends Object
implements Comparable<ConfigurationPropertyName>
A configuration property name composed of elements separated by dots. User created
 names may contain the characters "
a-z" "0-9" and "-", they must
 be lower-case and must start with an alphanumeric 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
- Since:
- 2.0.0
- Author:
- Phillip Webb, Madhura Bhave
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumThe various forms that a non-indexed element value can take.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final ConfigurationPropertyNameAn emptyConfigurationPropertyName.
- 
Method SummaryModifier and TypeMethodDescriptionstatic ConfigurationPropertyNameadapt(CharSequence name, char separator) Create aConfigurationPropertyNameby adapting the given source.Create a newConfigurationPropertyNameby appending the given suffix.append(ConfigurationPropertyName suffix) Create a newConfigurationPropertyNameby appending the given suffix.chop(int size) Return a newConfigurationPropertyNameby chopping this name to the givensize.intbooleangetElement(int elementIndex, ConfigurationPropertyName.Form form) Return an element in the name in the given form.Return the last element in the name in the given form.intReturn the total number of elements in the name.Return the parent of thisConfigurationPropertyNameorEMPTYif there is no parent.inthashCode()booleanReturntrueif any element in the name is indexed.booleanReturnstrueif this element is an ancestor (immediate or nested parent) of the specified name.booleanisEmpty()Returnstrueif thisConfigurationPropertyNameis empty.booleanReturn if the last element in the name is indexed.booleanisNumericIndex(int elementIndex) Return if the element in the name is indexed and numeric.booleanReturnstrueif this element is an immediate parent of the specified name.static booleanisValid(CharSequence name) Returns if the given name is valid.static ConfigurationPropertyNameof(CharSequence name) Return aConfigurationPropertyNamefor the specified string.static ConfigurationPropertyNameofIfValid(CharSequence name) Return aConfigurationPropertyNamefor the specified string ornullif the name is not valid.subName(int offset) Return a newConfigurationPropertyNameby based on this name offset by specific element index.toString()
- 
Field Details- 
EMPTYAn emptyConfigurationPropertyName.
 
- 
- 
Method Details- 
isEmptypublic boolean isEmpty()Returnstrueif thisConfigurationPropertyNameis empty.- Returns:
- trueif the name is empty
 
- 
isLastElementIndexedpublic boolean isLastElementIndexed()Return if the last element in the name is indexed.- Returns:
- trueif the last element is indexed
 
- 
hasIndexedElementpublic boolean hasIndexedElement()Returntrueif any element in the name is indexed.- Returns:
- if the element has one or more indexed elements
- Since:
- 2.2.10
 
- 
isNumericIndexpublic boolean isNumericIndex(int elementIndex) Return if the element in the name is indexed and numeric.- Parameters:
- elementIndex- the index of the element
- Returns:
- trueif the element is indexed and numeric
 
- 
getLastElementReturn the last element in the name in the given form.- Parameters:
- form- the form to return
- Returns:
- the last element
 
- 
getElementReturn an element in the name in the given form.- Parameters:
- elementIndex- the element index
- form- the form to return
- Returns:
- the last element
 
- 
getNumberOfElementspublic int getNumberOfElements()Return the total number of elements in the name.- Returns:
- the number of elements
 
- 
appendCreate a newConfigurationPropertyNameby appending the given suffix.- Parameters:
- suffix- the elements to append
- Returns:
- a new ConfigurationPropertyName
- Throws:
- InvalidConfigurationPropertyNameException- if the result is not valid
 
- 
appendCreate a newConfigurationPropertyNameby appending the given suffix.- Parameters:
- suffix- the elements to append
- Returns:
- a new ConfigurationPropertyName
- Since:
- 2.5.0
 
- 
getParentReturn the parent of thisConfigurationPropertyNameorEMPTYif there is no parent.- Returns:
- the parent name
 
- 
chopReturn a newConfigurationPropertyNameby chopping this name to the givensize. For example,chop(1)on the namefoo.barwill returnfoo.- Parameters:
- size- the size to chop
- Returns:
- the chopped name
 
- 
subNameReturn a newConfigurationPropertyNameby based on this name offset by specific element index. For example,subName(1)on the namefoo.barwill returnbar.- Parameters:
- offset- the element offset
- Returns:
- the sub name
- Since:
- 2.5.0
 
- 
isParentOfReturnstrueif this element is an immediate parent of the specified name.- Parameters:
- name- the name to check
- Returns:
- trueif this name is an ancestor
 
- 
isAncestorOfReturnstrueif this element is an ancestor (immediate or nested parent) of the specified name.- Parameters:
- name- the name to check
- Returns:
- trueif this name is an ancestor
 
- 
compareTo- Specified by:
- compareToin interface- Comparable<ConfigurationPropertyName>
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
- 
isValidReturns if the given name is valid. If this method returnstruethen the name may be used withof(CharSequence)without throwing an exception.- Parameters:
- name- the name to test
- Returns:
- trueif the name is valid
 
- 
ofReturn aConfigurationPropertyNamefor the specified string.- Parameters:
- name- the source name
- Returns:
- a ConfigurationPropertyNameinstance
- Throws:
- InvalidConfigurationPropertyNameException- if the name is not valid
 
- 
ofIfValidReturn aConfigurationPropertyNamefor the specified string ornullif the name is not valid.- Parameters:
- name- the source name
- Returns:
- a ConfigurationPropertyNameinstance
- Since:
- 2.3.1
 
- 
adaptCreate aConfigurationPropertyNameby adapting the given source. Seeadapt(CharSequence, char, Function)for details.- Parameters:
- name- the name to parse
- separator- the separator used to split the name
- Returns:
- a ConfigurationPropertyName
 
 
-