Interface OriginLookup<K>

Type Parameters:
K - the lookup key type
All Known Implementing Classes:
ConfigTreePropertySource, OriginTrackedMapPropertySource, SystemEnvironmentPropertySourceEnvironmentPostProcessor.OriginAwareSystemEnvironmentPropertySource
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface OriginLookup<K>
An interface that may be implemented by an object that can lookup Origin information from a given key. Can be used to add origin support to existing classes.
Since:
2.0.0
Author:
Phillip Webb
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K> Origin
    getOrigin(Object source, K key)
    Attempt to look up the origin from the given source.
    getOrigin(K key)
    Return the origin of the given key or null if the origin cannot be determined.
    default String
    Return the implicit prefix that is applied when performing a lookup or null if no prefix is used.
    default boolean
    Return true if this lookup is immutable and has contents that will never change.
  • Method Details

    • getOrigin

      Origin getOrigin(K key)
      Return the origin of the given key or null if the origin cannot be determined.
      Parameters:
      key - the key to lookup
      Returns:
      the origin of the key or null
    • isImmutable

      default boolean isImmutable()
      Return true if this lookup is immutable and has contents that will never change.
      Returns:
      if the lookup is immutable
      Since:
      2.2.0
    • getPrefix

      default String getPrefix()
      Return the implicit prefix that is applied when performing a lookup or null if no prefix is used. Prefixes can be used to disambiguate keys that would otherwise clash. For example, if multiple applications are running on the same machine a different prefix can be set on each application to ensure that different environment variables are used.
      Returns:
      the prefix applied by the lookup class or null.
      Since:
      2.5.0
    • getOrigin

      static <K> Origin getOrigin(Object source, K key)
      Attempt to look up the origin from the given source. If the source is not a OriginLookup or if an exception occurs during lookup then null is returned.
      Type Parameters:
      K - the key type
      Parameters:
      source - the source object
      key - the key to lookup
      Returns:
      an Origin or null