001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.collections4;
018
019import java.util.Map;
020
021/**
022 * The "write" subset of the {@link Map} interface.
023 * <p>
024 * NOTE: in the original {@link Map} interface, {@link Map#put(Object, Object)} is known
025 * to have the same return type as {@link Map#get(Object)}, namely {@code V}. {@link Put}
026 * makes no assumptions in this regard (there is no association with, nor even knowledge
027 * of, a "reading" interface) and thus defines {@link #put(Object, Object)} as returning
028 * {@link Object}.
029 *
030 * @param <K> the type of the keys in this map
031 * @param <V> the type of the values in this map
032 *
033 * @since 4.0
034 * @see Get
035 */
036public interface Put<K, V> {
037
038    /**
039     * @see Map#clear()
040     */
041    void clear();
042
043    /**
044     * Note that the return type is Object, rather than V as in the Map interface.
045     * See the class Javadoc for further info.
046     *
047     * @param key key with which the specified value is to be associated
048     * @param value value to be associated with the specified key
049     * @return the previous value associated with <code>key</code>, or
050     *         <code>null</code> if there was no mapping for <code>key</code>.
051     *         (A <code>null</code> return can also indicate that the map
052     *         previously associated <code>null</code> with <code>key</code>,
053     *         if the implementation supports <code>null</code> values.)
054     * @see Map#put(Object, Object)
055     */
056    Object put(K key, V value);
057
058    /**
059     * @param t mappings to be stored in this map
060     * @see Map#putAll(Map)
061     */
062    void putAll(Map<? extends K, ? extends V> t);
063
064}