View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.collections4;
18  
19  import java.util.Map;
20  
21  /**
22   * The "write" subset of the {@link Map} interface.
23   * <p>
24   * NOTE: in the original {@link Map} interface, {@link Map#put(Object, Object)} is known
25   * to have the same return type as {@link Map#get(Object)}, namely {@code V}. {@link Put}
26   * makes no assumptions in this regard (there is no association with, nor even knowledge
27   * of, a "reading" interface) and thus defines {@link #put(Object, Object)} as returning
28   * {@link Object}.
29   * </p>
30   *
31   * @param <K> the type of the keys in this map
32   * @param <V> the type of the values in this map
33   *
34   * @since 4.0
35   * @see Get
36   */
37  public interface Put<K, V> {
38  
39      /**
40       * @see Map#clear()
41       */
42      void clear();
43  
44      /**
45       * Note that the return type is Object, rather than V as in the Map interface.
46       * See the class Javadoc for further info.
47       *
48       * @param key key with which the specified value is to be associated
49       * @param value value to be associated with the specified key
50       * @return the previous value associated with {@code key}, or
51       *         {@code null} if there was no mapping for {@code key}.
52       *         (A {@code null} return can also indicate that the map
53       *         previously associated {@code null} with {@code key},
54       *         if the implementation supports {@code null} values.)
55       * @see Map#put(Object, Object)
56       */
57      Object put(K key, V value);
58  
59      /**
60       * @param t mappings to be stored in this map
61       * @see Map#putAll(Map)
62       */
63      void putAll(Map<? extends K, ? extends V> t);
64  
65  }