Class AttrValues

java.lang.Object
codes.grow.packages.betterstack.logging.AttrValues

public final class AttrValues extends Object
Normalises attribute values (AttrValue) into the kinds the SDK accepts.

An attribute value is one of: String, Long (all integral numbers), Double (all floating point numbers), Boolean, List<Object> of attribute values or Map<String, Object> of attribute values. normalize(Object) converts other inputs: Integer/Short/Byte/BigInteger (when it fits) become Long, Float/BigDecimal become Double, arrays and collections become immutable lists, maps become immutable insertion-ordered maps with string keys and anything else becomes its toString(). null has no attribute value: null list items and map entries with a null value are dropped; normalize(java.lang.Object) of a bare null returns the empty string (kept for compatibility).

  • Method Details

    • normalize

      public static Object normalize(Object value)
      Returns the normalised, deeply immutable form of value.
      Parameters:
      value - any value
      Returns:
      a valid attribute value ("" for null)
    • normalizeMap

      public static Map<String,Object> normalizeMap(Map<?,?> map)
      Normalises every value of a map; keys become strings. null gives an empty map.
      Parameters:
      map - attributes (may be null)
      Returns:
      an immutable, insertion-ordered copy
    • merge

      @SafeVarargs public static Map<String,Object> merge(Map<String,?>... maps)
      Merges attribute maps; later maps win on key collisions.
      Parameters:
      maps - maps in order of increasing precedence (null entries are skipped)
      Returns:
      an immutable merged map