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 * @since 4.0 34 * @see Get 35 */ 36 public interface Put<K, V> { 37 38 /** 39 * Removes all of the mappings from this map. 40 * 41 * @see Map#clear() 42 */ 43 void clear(); 44 45 /** 46 * Associates the specified value with the specified key in this map. 47 * <p> 48 * Note that the return type is Object, rather than V as in the Map interface. 49 * See the class Javadoc for further info. 50 * </p> 51 * 52 * @param key key with which the specified value is to be associated 53 * @param value value to be associated with the specified key 54 * @return the previous value associated with {@code key}, or 55 * {@code null} if there was no mapping for {@code key}. 56 * (A {@code null} return can also indicate that the map 57 * previously associated {@code null} with {@code key}, 58 * if the implementation supports {@code null} values.) 59 * @see Map#put(Object, Object) 60 */ 61 Object put(K key, V value); 62 63 /** 64 * Copies all of the mappings from the specified map to this map. 65 * 66 * @param t mappings to be stored in this map 67 * @see Map#putAll(Map) 68 */ 69 void putAll(Map<? extends K, ? extends V> t); 70 71 }