Merge branch 'master' of ../controller
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / ModifiableMapPhase.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.util;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Mutable;
15
16 /**
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}.
24  *
25  * @param <K>
26  *            the type of keys maintained by this map
27  * @param <V>
28  *            the type of mapped values
29  */
30 @Beta
31 public interface ModifiableMapPhase<K, V> extends Map<K, V>, Mutable {
32     /**
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.
36      *
37      * @return An unmodifiable version of this map.
38      */
39     @NonNull Map<K, V> toUnmodifiableMap();
40 }