boolean (T object) { final int key = object.hashCode(); final Pair<SoftReference<T>, Boolean> entry = myCache.get(key); if (entry == null || entry.first.get() != object) { boolean value = myCondition.value(object); myCache.put(key, Pair.create(new SoftReference<>(object), value)); return value; } return entry.second; }