![JAR search and dependency download from the Maven repository](/logo.png)
javadoc.src-html.com.google.common.collect.GenericMapMaker.html Maven / Gradle / Ivy
The newest version!
001 /*
002 * Copyright (C) 2010 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS-IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package com.google.common.collect;
018
019 import com.google.common.annotations.Beta;
020 import com.google.common.annotations.GwtCompatible;
021 import com.google.common.annotations.GwtIncompatible;
022 import com.google.common.base.Equivalence;
023 import com.google.common.base.Function;
024 import com.google.common.base.Objects;
025 import com.google.common.collect.MapMaker.RemovalListener;
026 import com.google.common.collect.MapMaker.RemovalNotification;
027
028 import java.util.concurrent.ConcurrentMap;
029 import java.util.concurrent.TimeUnit;
030
031 /**
032 * A class exactly like {@link MapMaker}, except restricted in the types of maps it can build.
033 * For the most part, you should probably just ignore the existence of this class.
034 *
035 * @param <K0> the base type for all key types of maps built by this map maker
036 * @param <V0> the base type for all value types of maps built by this map maker
037 * @author Kevin Bourrillion
038 * @since 7.0
039 */
040 @Beta
041 @GwtCompatible(emulated = true)
042 public abstract class GenericMapMaker<K0, V0> {
043 @GwtIncompatible("To be supported")
044 enum NullListener implements RemovalListener<Object, Object> {
045 INSTANCE;
046
047 @Override
048 public void onRemoval(RemovalNotification<Object, Object> notification) {}
049 }
050
051 // Set by MapMaker, but sits in this class to preserve the type relationship
052 @GwtIncompatible("To be supported")
053 RemovalListener<K0, V0> removalListener;
054
055 // No subclasses but our own
056 GenericMapMaker() {}
057
058 /**
059 * See {@link MapMaker#keyEquivalence}.
060 */
061 @GwtIncompatible("To be supported")
062 abstract GenericMapMaker<K0, V0> keyEquivalence(Equivalence<Object> equivalence);
063
064 /**
065 * See {@link MapMaker#valueEquivalence}.
066 */
067 @GwtIncompatible("To be supported")
068 abstract GenericMapMaker<K0, V0> valueEquivalence(Equivalence<Object> equivalence);
069
070 /**
071 * See {@link MapMaker#initialCapacity}.
072 */
073 public abstract GenericMapMaker<K0, V0> initialCapacity(int initialCapacity);
074
075 /**
076 * See {@link MapMaker#maximumSize}.
077 */
078 abstract GenericMapMaker<K0, V0> maximumSize(int maximumSize);
079
080 /**
081 * See {@link MapMaker#strongKeys}.
082 */
083 abstract GenericMapMaker<K0, V0> strongKeys();
084
085 /**
086 * See {@link MapMaker#concurrencyLevel}.
087 */
088 public abstract GenericMapMaker<K0, V0> concurrencyLevel(int concurrencyLevel);
089
090 /**
091 * See {@link MapMaker#weakKeys}.
092 */
093 @GwtIncompatible("java.lang.ref.WeakReference")
094 public abstract GenericMapMaker<K0, V0> weakKeys();
095
096 /**
097 * See {@link MapMaker#strongValues}.
098 */
099 abstract GenericMapMaker<K0, V0> strongValues();
100
101 /**
102 * See {@link MapMaker#softKeys}.
103 */
104 @Deprecated
105 @GwtIncompatible("java.lang.ref.SoftReference")
106 public abstract GenericMapMaker<K0, V0> softKeys();
107
108 /**
109 * See {@link MapMaker#weakValues}.
110 */
111 @GwtIncompatible("java.lang.ref.WeakReference")
112 public abstract GenericMapMaker<K0, V0> weakValues();
113
114 /**
115 * See {@link MapMaker#softValues}.
116 */
117 @GwtIncompatible("java.lang.ref.SoftReference")
118 public abstract GenericMapMaker<K0, V0> softValues();
119
120 /**
121 * See {@link MapMaker#expiration}.
122 */
123 @Deprecated
124 public
125 abstract GenericMapMaker<K0, V0> expiration(long duration, TimeUnit unit);
126
127 /**
128 * See {@link MapMaker#expireAfterWrite}.
129 */
130 abstract GenericMapMaker<K0, V0> expireAfterWrite(long duration, TimeUnit unit);
131
132 /**
133 * See {@link MapMaker#expireAfterAccess}.
134 */
135 @GwtIncompatible("To be supported")
136 abstract GenericMapMaker<K0, V0> expireAfterAccess(long duration, TimeUnit unit);
137
138 /*
139 * Note that MapMaker's removalListener() is not here, because once you're interacting with a
140 * GenericMapMaker you've already called that, and shouldn't be calling it again.
141 */
142
143 @SuppressWarnings("unchecked") // safe covariant cast
144 @GwtIncompatible("To be supported")
145 <K extends K0, V extends V0> RemovalListener<K, V> getRemovalListener() {
146 return (RemovalListener<K, V>) Objects.firstNonNull(removalListener, NullListener.INSTANCE);
147 }
148
149 /**
150 * See {@link MapMaker#makeMap}.
151 */
152 public abstract <K extends K0, V extends V0> ConcurrentMap<K, V> makeMap();
153
154 /**
155 * See {@link MapMaker#makeCustomMap}.
156 */
157 @GwtIncompatible("MapMakerInternalMap")
158 abstract <K, V> MapMakerInternalMap<K, V> makeCustomMap();
159
160 /**
161 * See {@link MapMaker#makeComputingMap}.
162 */
163 @Deprecated
164 public abstract <K extends K0, V extends V0> ConcurrentMap<K, V> makeComputingMap(
165 Function<? super K, ? extends V> computingFunction);
166 }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy