    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 *      https://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 */
    017
    018package org.apache.commons.collections4;
    019
    020import java.util.Map;
    021
    022/**
    023 * The "write" subset of the {@link Map} interface.
    024 * <p>
    025 * NOTE: in the original {@link Map} interface, {@link Map#put(Object, Object)} is known to have the same return type as {@link Map#get(Object)}, namely
    026 * {@code V}. {@link Put} makes no assumptions in this regard (there is no association with, nor even knowledge of, a "reading" interface) and thus defines
    027 * {@link #put(Object, Object)} as returning {@link Object}.
    028 * </p>
    029 *
    030 * @param <K> The type of the keys in this map.
    031 * @param <V> The type of the values in this map.
    032 * @since 4.0
    033 * @see Get
    034 */
    035public interface Put<K, V> {
    036
    037    /**
    038     * Removes all of the mappings from this map.
    039     *
    040     * @see Map#clear()
    041     */
    042    void clear();
    043
    044    /**
    045     * Associates the specified value with the specified key in this map.
    046     * <p>
    047     * Note that the return type is Object, rather than V as in the Map interface. See the class Javadoc for further info.
    048     * </p>
    049     *
    050     * @param key   key with which the specified value is to be associated.
    051     * @param value value to be associated with the specified key.
    052     * @return The previous value associated with {@code key}, or {@code null} if there was no mapping for {@code key}. (A {@code null} return can also indicate
    053     *         that the map previously associated {@code null} with {@code key}, if the implementation supports {@code null} values.)
    054     * @see Map#put(Object, Object)
    055     */
    056    Object put(K key, V value);
    057
    058    /**
    059     * Copies all of the mappings from the specified map to this map.
    060     *
    061     * @param t mappings to be stored in this map.
    062     * @see Map#putAll(Map)
    063     */
    064    void putAll(Map<? extends K, ? extends V> t);
    065}