org.springframework.boot.context.properties.source

Class ConfigurationPropertyName

  • java.lang.Object
    • org.springframework.boot.context.properties.source.ConfigurationPropertyName
  • All Implemented Interfaces:
    java.lang.Comparable<ConfigurationPropertyName>


    public final class ConfigurationPropertyName
    extends java.lang.Object
    implements java.lang.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
    See Also:
    of(CharSequence), ConfigurationPropertySource
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Returns true if this ConfigurationPropertyName is empty.
        Returns:
        true if the name is empty
      • isLastElementIndexed

        public boolean isLastElementIndexed()
        Return if the last element in the name is indexed.
        Returns:
        true if the last element is indexed
      • hasIndexedElement

        public boolean hasIndexedElement()
        Return true if any element in the name is indexed.
        Returns:
        if the element has one or more indexed elements
        Since:
        2.2.10
      • isNumericIndex

        public boolean isNumericIndex(int elementIndex)
        Return if the element in the name is indexed and numeric.
        Parameters:
        elementIndex - the index of the element
        Returns:
        true if the element is indexed and numeric
      • getLastElement

        public java.lang.String getLastElement(ConfigurationPropertyName.Form form)
        Return the last element in the name in the given form.
        Parameters:
        form - the form to return
        Returns:
        the last element
      • getElement

        public java.lang.String getElement(int elementIndex,
                                           ConfigurationPropertyName.Form form)
        Return an element in the name in the given form.
        Parameters:
        elementIndex - the element index
        form - the form to return
        Returns:
        the last element
      • getNumberOfElements

        public int getNumberOfElements()
        Return the total number of elements in the name.
        Returns:
        the number of elements
      • chop

        public ConfigurationPropertyName chop(int size)
        Return a new ConfigurationPropertyName by chopping this name to the given size. For example, chop(1) on the name foo.bar will return foo.
        Parameters:
        size - the size to chop
        Returns:
        the chopped name
      • subName

        public ConfigurationPropertyName subName(int offset)
        Return a new ConfigurationPropertyName by based on this name offset by specific element index. For example, chop(1) on the name foo.bar will return bar.
        Parameters:
        offset - the element offset
        Returns:
        the sub name
        Since:
        2.5.0
      • isParentOf

        public boolean isParentOf(ConfigurationPropertyName name)
        Returns true if this element is an immediate parent of the specified name.
        Parameters:
        name - the name to check
        Returns:
        true if this name is an ancestor
      • isAncestorOf

        public boolean isAncestorOf(ConfigurationPropertyName name)
        Returns true if this element is an ancestor (immediate or nested parent) of the specified name.
        Parameters:
        name - the name to check
        Returns:
        true if this name is an ancestor
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isValid

        public static boolean isValid(java.lang.CharSequence name)
        Returns if the given name is valid. If this method returns true then the name may be used with of(CharSequence) without throwing an exception.
        Parameters:
        name - the name to test
        Returns:
        true if the name is valid