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 org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Mutable;
17 * A {@link Map} which can be modified and supports efficient conversion to an
18 * unmodifiable map. This interface is the logical counterpart to
19 * {@link UnmodifiableMapPhase}, but it does not require implementations of
20 * {@link #toUnmodifiableMap()} to return an implementation of that interface.
21 * The reason for that empty and singleton mappings are efficiently represented
22 * as {@link ImmutableMap}, which does not implement
23 * {@link UnmodifiableMapPhase}.
26 * the type of keys maintained by this map
28 * the type of mapped values
31 public interface ModifiableMapPhase<K, V> extends Map<K, V>, Mutable {
33 * Return an isolated unmodifiable version of this map. Returned object must not allow removal, addition or changing
34 * of mappings. Its mappings must match the mappings currently present in this map, but must not be affected by any
35 * subsequent changes to this map.
37 * @return An unmodifiable version of this map.
39 @NonNull Map<K, V> toUnmodifiableMap();