View Javadoc
1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2026, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v2.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.kryo;
15  
16  import com.esotericsoftware.kryo.kryo5.Serializer;
17  
18  /**
19   * V5 MDC map: whole-map cache is {@link BiMapType#IDENTITY}. Keys stay on {@link BasicStringSerializer}.
20   * Values use the caller-supplied codec, the same
21   * {@link MultiEventCompressedStringSerializer} as message, string arguments, and
22   * KVP string values.
23   */
24  public class MDCPropertyMapSerializerV5 extends MDCPropertyMapSerializer {
25  
26      public MDCPropertyMapSerializerV5(Serializer<String> valueSerializer) {
27          this(1024, valueSerializer);
28      }
29  
30      public MDCPropertyMapSerializerV5(int capacity, Serializer<String> valueSerializer) {
31          super(BiMapType.IDENTITY, capacity, new BasicStringSerializer(capacity), requireValueSerializer(valueSerializer));
32      }
33  
34      private static Serializer<String> requireValueSerializer(Serializer<String> valueSerializer) {
35          if (valueSerializer == null) {
36              throw new IllegalArgumentException("valueSerializer cannot be null");
37          }
38          return valueSerializer;
39      }
40  }