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.core.kryo;
15  
16  public interface BidirectionalObjectToIdMap<V> {
17  
18      /**
19       * Returns the id for the given value or null if the value is not mapped.
20       */
21      Integer getIdByValue(V value);
22  
23  
24      /**
25       * Inserts a new entry mapping an id to the given value.
26       * Reuses an id freed by LRU eviction when the map is at capacity;
27       * otherwise assigns the next unused id.
28       * Returns the assigned id.
29       */
30      Integer insertNewEntryOnWrite(V value);
31  
32  
33      /**
34       * Inserts a new entry mapping the given id to the given value.
35       *
36       * <p>Any existing entry with the same value if removed from the valueToId map.</p>
37       *
38       * Returns the existing value mapped to the given id or null if there was no existing mapping.
39       */
40      V insertNewEntryOnRead(int id, V value);
41  
42  
43      /**
44       * Returns the value mapped to the given id or null if there is no such mapping.
45       */
46      public V getValueById(int id);
47  }