guava/src/com/google/common/graph/MapRetrievalCache.java
@Override
  protected V getIfCached(@Nullable Object key) {
    V value = super.getIfCached(key);
    if (value != null) {
      return value;
    }

    // Store a local reference to the cache entry. If the backing map is immutable, this,
    // in combination with immutable cache entries, will ensure a thread-safe cache.
    CacheEntry<K, V> entry;

    // Check cache. We use == on purpose because it's cheaper and a cache miss is ok.
    entry = cacheEntry1;
    if (entry != null && entry.key == key) {
      return entry.value;
    }
    entry = cacheEntry2;
    if (entry != null && entry.key == key) {
      // Promote second cache entry to first so the access pattern
      // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time.
      addToCache(entry);
      return entry.value;
    }
    return null;
  }
@Override
  protected V getIfCached(@Nullable Object key) {
    V value = super.getIfCached(key);
    if (value != null) {
      return value;
    }

    // Store a local reference to the cache entry. If the backing map is immutable, this,
    // in combination with immutable cache entries, will ensure a thread-safe cache.
    CacheEntry<K, V> entry;

    // Check cache. We use == on purpose because it's cheaper and a cache miss is ok.
    entry = cacheEntry1;
    if (entry != null && entry.key == key) {
      return entry.value;
    }
    entry = cacheEntry2;
    if (entry != null && entry.key == key) {
      // Promote second cache entry to first so the access pattern
      // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time.
      addToCache(entry);
      return entry.value;
    }
    return null;
  }
@ Override protected V getIfCached ( @ Nullable Object key ) { V value = super . getIfCached ( key ) ; if ( value != null ) { return value ; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry < K , V > entry ; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1 ; if ( entry != null && entry . key == key ) { return entry . value ; } entry = cacheEntry2 ; if ( entry != null && entry . key == key ) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache ( entry ) ; return entry . value ; } return null ; }
Internal methods ('protected' is still package-visible, but treat as only subclass-visible)
Internal methods ( protected is still package - visible but treat as only subclass - visible )