Class ConfigDataLocation

java.lang.Object
org.springframework.boot.context.config.ConfigDataLocation
All Implemented Interfaces:
OriginProvider

public final class ConfigDataLocation extends Object implements OriginProvider
A user specified location that can be resolved to one or more config data resources. A ConfigDataLocation is a simple wrapper around a String value. The exact format of the value will depend on the underlying technology, but is usually a URL like syntax consisting of a prefix and path. For example, crypt:somehost/somepath.

Locations can be mandatory or optional. Optional locations are prefixed with optional:.

Since:
2.4.0
  • Field Details

  • Method Details

    • isOptional

      public boolean isOptional()
      Return if the location is optional and should ignore ConfigDataNotFoundException.
      Returns:
      if the location is optional
    • getValue

      public String getValue()
      Return the value of the location (always excluding any user specified optional: prefix).
      Returns:
      the location value
    • hasPrefix

      public boolean hasPrefix(String prefix)
      Return if getValue() has the specified prefix.
      Parameters:
      prefix - the prefix to check
      Returns:
      if the value has the prefix
    • getNonPrefixedValue

      public String getNonPrefixedValue(String prefix)
      Return getValue() with the specified prefix removed. If the location does not have the given prefix then the getValue() is returned unchanged.
      Parameters:
      prefix - the prefix to check
      Returns:
      the value with the prefix removed
    • getOrigin

      public Origin getOrigin()
      Description copied from interface: OriginProvider
      Return the source origin or null if the origin is not known.
      Specified by:
      getOrigin in interface OriginProvider
      Returns:
      the origin or null
    • split

      public ConfigDataLocation[] split()
      Return an array of ConfigDataLocation elements built by splitting this ConfigDataLocation around a delimiter of ";".
      Returns:
      the split locations
      Since:
      2.4.7
    • split

      public ConfigDataLocation[] split(String delimiter)
      Return an array of ConfigDataLocation elements built by splitting this ConfigDataLocation around the specified delimiter.
      Parameters:
      delimiter - the delimiter to split on
      Returns:
      the split locations
      Since:
      2.4.7
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static ConfigDataLocation of(String location)
      Factory method to create a new ConfigDataLocation from a string.
      Parameters:
      location - the location string
      Returns:
      a ConfigDataLocation instance or null if no location was provided