Class ContextPairs.Pairs<T>

java.lang.Object
org.springframework.boot.logging.structured.ContextPairs.Pairs<T>
Type Parameters:
T - the item type
Enclosing class:
ContextPairs

public class ContextPairs.Pairs<T> extends Object
Callback used to add pairs.
  • Method Details

    • addMapEntries

      public <K, V> void addMapEntries(Function<T,Map<String,V>> extractor)
      Add pairs from map entries.
      Type Parameters:
      K - the map key type
      V - the map value type
      Parameters:
      extractor - the extractor used to provide the map
    • add

      public <E, V> void add(Function<T,Iterable<E>> elementsExtractor, JsonWriter.PairExtractor<E> pairExtractor)
      Add pairs from an iterable.
      Type Parameters:
      E - the element type
      V - the value type
      Parameters:
      elementsExtractor - the extractor used to provide the iterable
      pairExtractor - the extractor used to provide the name and value
    • add

      public <E, V> void add(Function<T,Iterable<E>> elementsExtractor, Function<E,String> nameExtractor, Function<E,V> valueExtractor)
      Add pairs from an iterable.
      Type Parameters:
      E - the element type
      V - the value type
      Parameters:
      elementsExtractor - the extractor used to provide the iterable
      nameExtractor - the extractor used to provide the name
      valueExtractor - the extractor used to provide the value
    • add

      public <V> void add(BiConsumer<T,BiConsumer<String,V>> pairs)
      Add pairs using the given callback.
      Type Parameters:
      V - the value type
      Parameters:
      pairs - callback provided with the item and consumer that can be called to actually add the pairs