2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.util;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableMap;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.concepts.Mutable;
17 * A {@link Map} which can be modified and supports efficient conversion to an unmodifiable map. This interface is the
18 * logical counterpart to {@link UnmodifiableMapPhase}, but it does not require implementations of {@link #toUnmodifiableMap()}
19 * to return an implementation of that interface. The reason for that empty and singleton mappings are efficiently
20 * represented as {@link ImmutableMap}, which does not implement {@link UnmodifiableMapPhase}.
22 * @param <K> the type of keys maintained by this map
23 * @param <V> the type of mapped values
26 public interface ModifiableMapPhase<K, V> extends Map<K, V>, Mutable {
28 * Return an isolated unmodifiable version of this map. Returned object must not allow removal, addition or changing
29 * of mappings. Its mappings must match the mappings currently present in this map, but must not be affected by any
30 * subsequent changes to this map.
32 * @return An unmodifiable version of this map.
34 @Nonnull Map<K, V> toUnmodifiableMap();