001/*
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2026, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v2.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.kryo;
015
016public interface BidirectionalObjectToIdMap<V> {
017
018    /**
019     * Returns the id for the given value or null if the value is not mapped.
020     */
021    Integer getIdByValue(V value);
022
023
024    /**
025     * Inserts a new entry mapping an id to the given value.
026     * Reuses an id freed by LRU eviction when the map is at capacity;
027     * otherwise assigns the next unused id.
028     * Returns the assigned id.
029     */
030    Integer insertNewEntryOnWrite(V value);
031
032
033    /**
034     * Inserts a new entry mapping the given id to the given value.
035     *
036     * <p>Any existing entry with the same value if removed from the valueToId map.</p>
037     *
038     * Returns the existing value mapped to the given id or null if there was no existing mapping.
039     */
040    V insertNewEntryOnRead(int id, V value);
041
042
043    /**
044     * Returns the value mapped to the given id or null if there is no such mapping.
045     */
046    public V getValueById(int id);
047}