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.Collection;
020import java.util.Map;
021import java.util.Set;
022
023/**
024 * The "read" subset of the {@link Map} interface.
025 *
026 * @param <K> the type of the keys in this map
027 * @param <V> the type of the values in this map
028 * @since 4.0
029 * @see Put
030 */
031public interface Get<K, V> {
032
033    /**
034     * Tests for presence of a given key.
035     *
036     * @param key key whose presence in this map is to be tested
037     * @return {@code true} if this map contains a mapping for the specified key
038     * @see Map#containsKey(Object)
039     */
040    boolean containsKey(Object key);
041
042    /**
043     * Tests for presence of a given value.
044     *
045     * @param value value whose presence in this map is to be tested
046     * @return {@code true} if this map maps one or more keys to the specified value
047     * @see Map#containsValue(Object)
048     */
049    boolean containsValue(Object value);
050
051    /**
052     * Gets a set view of the mappings contained in this map.
053     *
054     * @return a set view of the mappings contained in this map.
055     * @see Map#entrySet()
056     */
057    Set<Map.Entry<K, V>> entrySet();
058
059    /**
060     * Gets a value at a given key.
061     *
062     * @param key the key whose associated value is to be returned
063     * @return the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key
064     * @see Map#get(Object)
065     */
066    V get(Object key);
067
068    /**
069     * Tests whether this instance contains any key-value mappings.
070     *
071     * @return {@code true} if this map contains no key-value mappings
072     * @see Map#isEmpty()
073     */
074    boolean isEmpty();
075
076    /**
077     * Gets a view of the keys contained in this map.
078     *
079     * @return a set view of the keys contained in this map
080     * @see Map#keySet()
081     */
082    Set<K> keySet();
083
084    /**
085     * Remove a key-value mappings.
086     *
087     * @param key key whose mapping is to be removed from the map
088     * @return the previous value associated with {@code key}, or {@code null} if there was no mapping for {@code key}.
089     * @see Map#remove(Object)
090     */
091    V remove(Object key);
092
093    /**
094     * Gets the number of key-value mappings in this map.
095     *
096     * @return the number of key-value mappings in this map.
097     * @see Map#size()
098     */
099    int size();
100
101    /**
102     * Gets a a collection view of the values contained in this map.
103     *
104     * @return a collection view of the values contained in this map.
105     * @see Map#values()
106     */
107    Collection<V> values();
108
109}