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.Collection;
20 import java.util.Map;
21 import java.util.Set;
22
23 /**
24 * The "read" subset of the {@link Map} interface.
25 *
26 * @param <K> the type of the keys in this map
27 * @param <V> the type of the values in this map
28 * @since 4.0
29 * @see Put
30 */
31 public interface Get<K, V> {
32
33 /**
34 * Tests for presence of a given key.
35 *
36 * @param key key whose presence in this map is to be tested
37 * @return {@code true} if this map contains a mapping for the specified key
38 * @see Map#containsKey(Object)
39 */
40 boolean containsKey(Object key);
41
42 /**
43 * Tests for presence of a given value.
44 *
45 * @param value value whose presence in this map is to be tested
46 * @return {@code true} if this map maps one or more keys to the specified value
47 * @see Map#containsValue(Object)
48 */
49 boolean containsValue(Object value);
50
51 /**
52 * Gets a set view of the mappings contained in this map.
53 *
54 * @return a set view of the mappings contained in this map.
55 * @see Map#entrySet()
56 */
57 Set<Map.Entry<K, V>> entrySet();
58
59 /**
60 * Gets a value at a given key.
61 *
62 * @param key the key whose associated value is to be returned
63 * @return the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key
64 * @see Map#get(Object)
65 */
66 V get(Object key);
67
68 /**
69 * Tests whether this instance contains any key-value mappings.
70 *
71 * @return {@code true} if this map contains no key-value mappings
72 * @see Map#isEmpty()
73 */
74 boolean isEmpty();
75
76 /**
77 * Gets a view of the keys contained in this map.
78 *
79 * @return a set view of the keys contained in this map
80 * @see Map#keySet()
81 */
82 Set<K> keySet();
83
84 /**
85 * Remove a key-value mappings.
86 *
87 * @param key key whose mapping is to be removed from the map
88 * @return the previous value associated with {@code key}, or {@code null} if there was no mapping for {@code key}.
89 * @see Map#remove(Object)
90 */
91 V remove(Object key);
92
93 /**
94 * Gets the number of key-value mappings in this map.
95 *
96 * @return the number of key-value mappings in this map.
97 * @see Map#size()
98 */
99 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 }