AbstractSerializationProxy(Strength keyStrength, Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, int maximumSize, int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener, ConcurrentMap<K, V> delegate) { this.keyStrength = keyStrength; this.valueStrength = valueStrength; this.keyEquivalence = keyEquivalence; this.valueEquivalence = valueEquivalence; this.expireAfterWriteNanos = expireAfterWriteNanos; this.expireAfterAccessNanos = expireAfterAccessNanos; this.maximumSize = maximumSize; this.concurrencyLevel = concurrencyLevel; this.removalListener = removalListener; this.delegate = delegate; }
@SuppressWarnings("deprecation") public static <K, V> ConcurrentMap<K, V> makeSoftValueComputingMapWithRemoveListenr(MapMaker maker, Function<? super K, ? extends V> computingFunction, final OtterRemovalListener listener) { return maker.softValues().removalListener(new RemovalListener<K, V>() { @Override public void onRemoval(RemovalNotification<K, V> notification) { if (notification == null) { return; } listener.onRemoval(notification.getKey(), notification.getValue()); } }).makeComputingMap(computingFunction); }
SerializationProxy(Strength keyStrength, Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, int maximumSize, int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener, ConcurrentMap<K, V> delegate) { super(keyStrength, valueStrength, keyEquivalence, valueEquivalence, expireAfterWriteNanos, expireAfterAccessNanos, maximumSize, concurrencyLevel, removalListener, delegate); }
ComputingSerializationProxy(Strength keyStrength, Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, int maximumSize, int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener, ConcurrentMap<K, V> delegate, Function<? super K, ? extends V> computingFunction) { super(keyStrength, valueStrength, keyEquivalence, valueEquivalence, expireAfterWriteNanos, expireAfterAccessNanos, maximumSize, concurrencyLevel, removalListener, delegate); this.computingFunction = computingFunction; }
public void testSetRemovalListener() { RemovalListener<Object, Object> testListener = new RemovalListener<Object, Object>() { @Override public void onRemoval(RemovalNotification<Object, Object> notification) {} }; MapMakerInternalMap<Object, Object> map = makeMap(createMapMaker().removalListener(testListener)); assertSame(testListener, map.removalListener); }
@SuppressWarnings("deprecation") public static <K, V> ConcurrentMap<K, V> makeSoftValueComputingMapWithRemoveListenr(Function<? super K, ? extends V> computingFunction, final OtterRemovalListener<K, V> listener) { return new MapMaker().softValues().removalListener(new RemovalListener<K, V>() { @Override public void onRemoval(RemovalNotification<K, V> notification) { if (notification == null) { return; } listener.onRemoval(notification.getKey(), notification.getValue()); } }).makeComputingMap(computingFunction); }
@SuppressWarnings("unchecked") // safe covariant cast @GwtIncompatible("To be supported") <K extends K0, V extends V0> RemovalListener<K, V> getRemovalListener() { return (RemovalListener<K, V>) Objects.firstNonNull(removalListener, NullListener.INSTANCE); }
@SuppressWarnings("unchecked") // safe covariant cast @GwtIncompatible("To be supported") <K extends K0, V extends V0> RemovalListener<K, V> getRemovalListener() { return (RemovalListener<K, V>) MoreObjects.firstNonNull(removalListener, NullListener.INSTANCE); }