1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */

15
16 package software.amazon.awssdk.core.util;
17
18 import java.util.Collection;
19 import java.util.Collections;
20 import java.util.Map;
21 import java.util.Set;
22 import software.amazon.awssdk.annotations.SdkProtectedApi;
23
24 /**
25  * Default implementation of {@link SdkAutoConstructMap}.
26  * <p>
27  * This is an empty, unmodifiable map.
28  *
29  * @param <K> The key type.
30  * @param <V> The value type.
31  */

32 @SdkProtectedApi
33 public final class DefaultSdkAutoConstructMap<K, V> implements SdkAutoConstructMap<K, V> {
34     private static final DefaultSdkAutoConstructMap INSTANCE = new DefaultSdkAutoConstructMap();
35
36     private final Map<K, V> impl = Collections.emptyMap();
37
38     private DefaultSdkAutoConstructMap() {
39     }
40
41     @SuppressWarnings("unchecked")
42     public static <K, V> DefaultSdkAutoConstructMap<K, V> getInstance() {
43         return (DefaultSdkAutoConstructMap<K, V>) INSTANCE;
44     }
45
46     @Override
47     public int size() {
48         return impl.size();
49     }
50
51     @Override
52     public boolean isEmpty() {
53         return impl.isEmpty();
54     }
55
56     @Override
57     public boolean containsKey(Object key) {
58         return impl.containsKey(key);
59     }
60
61     @Override
62     public boolean containsValue(Object value) {
63         return impl.containsValue(value);
64     }
65
66     @Override
67     public V get(Object key) {
68         return impl.get(key);
69     }
70
71     @Override
72     public V put(K key, V value) {
73         return impl.put(key, value);
74     }
75
76     @Override
77     public V remove(Object key) {
78         return impl.get(key);
79     }
80
81     @Override
82     public void putAll(Map<? extends K, ? extends V> m) {
83         impl.putAll(m);
84     }
85
86     @Override
87     public void clear() {
88         impl.clear();
89     }
90
91     @Override
92     public Set<K> keySet() {
93         return impl.keySet();
94     }
95
96     @Override
97     public Collection<V> values() {
98         return impl.values();
99     }
100
101     @Override
102     public Set<Entry<K, V>> entrySet() {
103         return impl.entrySet();
104     }
105
106     @Override
107     public boolean equals(Object o) {
108         return impl.equals(o);
109     }
110
111     @Override
112     public int hashCode() {
113         return impl.hashCode();
114     }
115
116     @Override
117     public String toString() {
118         return impl.toString();
119     }
120 }
121