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