    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 * </p>
    030 *
    031 * @param <K> the type of the keys in this map
    032 * @param <V> the type of the values in this map
    033 * @since 4.0
    034 * @see Get
    035 */
    036public interface Put<K, V> {
    037
    038    /**
    039     * Removes all of the mappings from this map.
    040     *
    041     * @see Map#clear()
    042     */
    043    void clear();
    044
    045    /**
    046     * Associates the specified value with the specified key in this map.
    047     * <p>
    048     * Note that the return type is Object, rather than V as in the Map interface.
    049     * See the class Javadoc for further info.
    050     * </p>
    051     *
    052     * @param key key with which the specified value is to be associated
    053     * @param value value to be associated with the specified key
    054     * @return the previous value associated with {@code key}, or
    055     *         {@code null} if there was no mapping for {@code key}.
    056     *         (A {@code null} return can also indicate that the map
    057     *         previously associated {@code null} with {@code key},
    058     *         if the implementation supports {@code null} values.)
    059     * @see Map#put(Object, Object)
    060     */
    061    Object put(K key, V value);
    062
    063    /**
    064     * Copies all of the mappings from the specified map to this map.
    065     *
    066     * @param t mappings to be stored in this map
    067     * @see Map#putAll(Map)
    068     */
    069    void putAll(Map<? extends K, ? extends V> t);
    070
    071}