/** Returns a fresh {@link MapMakerInternalMap} as specified by the given {@code builder}. */ static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, StrongKeyWeakValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, WeakKeyWeakValueEntry.Helper.<K, V>instance()); } throw new AssertionError(); }
/** * Returns a fresh {@link MapMakerInternalMap} with {@link MapMaker.Dummy} values but otherwise as * specified by the given {@code builder}. The returned {@link MapMakerInternalMap} will be * optimized to saved memory. Since {@link MapMaker.Dummy} is a singleton, we don't need to store * any values at all. Because of this optimization, {@code build.getValueStrength()} must be * {@link Strength#STRONG}. * * <p>This method is intended to only be used by the internal implementation of {@link Interners}, * since a map of dummy values is the exact use case there. */ static <K> MapMakerInternalMap<K, Dummy, ? extends InternalEntry<K, Dummy, ?>, ?> createWithDummyValues( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getValueStrength() == Strength.WEAK) { throw new IllegalArgumentException("Map cannot have both weak and dummy values"); } throw new AssertionError(); }
/** Returns a fresh {@link MapMakerInternalMap} as specified by the given {@code builder}. */ static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, StrongKeyWeakValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, WeakKeyWeakValueEntry.Helper.<K, V>instance()); } throw new AssertionError(); }
/** * Returns a fresh {@link MapMakerInternalMap} with {@link MapMaker.Dummy} values but otherwise as * specified by the given {@code builder}. The returned {@link MapMakerInternalMap} will be * optimized to saved memory. Since {@link MapMaker.Dummy} is a singleton, we don't need to store * any values at all. Because of this optimization, {@code build.getValueStrength()} must be * {@link Strength#STRONG}. * * <p>This method is intended to only be used by the internal implementation of {@link Interners}, * since a map of dummy values is the exact use case there. */ static <K> MapMakerInternalMap<K, Dummy, ? extends InternalEntry<K, Dummy, ?>, ?> createWithDummyValues( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getValueStrength() == Strength.WEAK) { throw new IllegalArgumentException("Map cannot have both weak and dummy values"); } throw new AssertionError(); }
/** Returns a fresh {@link MapMakerInternalMap} as specified by the given {@code builder}. */ static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, StrongKeyWeakValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, WeakKeyWeakValueEntry.Helper.<K, V>instance()); } throw new AssertionError(); }
/** * Returns a fresh {@link MapMakerInternalMap} with {@link MapMaker.Dummy} values but otherwise as * specified by the given {@code builder}. The returned {@link MapMakerInternalMap} will be * optimized to saved memory. Since {@link MapMaker.Dummy} is a singleton, we don't need to store * any values at all. Because of this optimization, {@code build.getValueStrength()} must be * {@link Strength#STRONG}. * * <p>This method is intended to only be used by the internal implementation of {@link Interners}, * since a map of dummy values is the exact use case there. */ static <K> MapMakerInternalMap<K, Dummy, ? extends InternalEntry<K, Dummy, ?>, ?> createWithDummyValues( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyDummyValueEntry.Helper.<K>instance()); } if (builder.getValueStrength() == Strength.WEAK) { throw new IllegalArgumentException("Map cannot have both weak and dummy values"); } throw new AssertionError(); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Returns a MapMakerInternalMap for the benefit of internal callers that use features of * that class not exposed through ConcurrentMap. */ @Override @GwtIncompatible("MapMakerInternalMap") <K, V> MapMakerInternalMap<K, V> makeCustomMap() { return new MapMakerInternalMap<K, V>(this); }
/** * Builds a thread-safe map, without on-demand computation of values. This method does not alter * the state of this {@code MapMaker} instance, so it can be invoked again to create multiple * independent maps. * * <p>The bulk operations {@code putAll}, {@code equals}, and {@code clear} are not guaranteed to * be performed atomically on the returned map. Additionally, {@code size} and {@code * containsValue} are implemented as bulk read operations, and thus may fail to observe concurrent * writes. * * @return a serializable concurrent map having the requested features */ @Override public <K, V> ConcurrentMap<K, V> makeMap() { if (!useCustomMap) { return new ConcurrentHashMap<K, V>(getInitialCapacity(), 0.75f, getConcurrencyLevel()); } return (nullRemovalCause == null) ? new MapMakerInternalMap<K, V>(this) : new NullConcurrentMap<K, V>(this); }
/** * Builds a thread-safe map, without on-demand computation of values. This method does not alter * the state of this {@code MapMaker} instance, so it can be invoked again to create multiple * independent maps. * * <p>The bulk operations {@code putAll}, {@code equals}, and {@code clear} are not guaranteed to * be performed atomically on the returned map. Additionally, {@code size} and {@code * containsValue} are implemented as bulk read operations, and thus may fail to observe concurrent * writes. * * @return a serializable concurrent map having the requested features */ @Override public <K, V> ConcurrentMap<K, V> makeMap() { if (!useCustomMap) { return new ConcurrentHashMap<K, V>(getInitialCapacity(), 0.75f, getConcurrencyLevel()); } return (nullRemovalCause == null) ? new MapMakerInternalMap<K, V>(this) : new NullConcurrentMap<K, V>(this); }
/** * Builds a thread-safe map, without on-demand computation of values. This method does not alter * the state of this {@code MapMaker} instance, so it can be invoked again to create multiple * independent maps. * * <p>The bulk operations {@code putAll}, {@code equals}, and {@code clear} are not guaranteed to * be performed atomically on the returned map. Additionally, {@code size} and {@code * containsValue} are implemented as bulk read operations, and thus may fail to observe concurrent * writes. * * @return a serializable concurrent map having the requested features */ @Override public <K, V> ConcurrentMap<K, V> makeMap() { if (!useCustomMap) { return new ConcurrentHashMap<K, V>(getInitialCapacity(), 0.75f, getConcurrencyLevel()); } return (nullRemovalCause == null) ? new MapMakerInternalMap<K, V>(this) : new NullConcurrentMap<K, V>(this); }
/** Returns a fresh {@link MapMakerInternalMap} as specified by the given {@code builder}. */ static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, StrongKeyWeakValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, WeakKeyWeakValueEntry.Helper.<K, V>instance()); } throw new AssertionError(); }
/** Returns a fresh {@link MapMakerInternalMap} as specified by the given {@code builder}. */ static <K, V> MapMakerInternalMap<K, V, ? extends InternalEntry<K, V, ?>, ?> create( MapMaker builder) { if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, StrongKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.STRONG && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, StrongKeyWeakValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.STRONG) { return new MapMakerInternalMap<>(builder, WeakKeyStrongValueEntry.Helper.<K, V>instance()); } if (builder.getKeyStrength() == Strength.WEAK && builder.getValueStrength() == Strength.WEAK) { return new MapMakerInternalMap<>(builder, WeakKeyWeakValueEntry.Helper.<K, V>instance()); } throw new AssertionError(); }