Package tenapull.sync
Class WeakInstancesTracker<K,I>
java.lang.Object
tenapull.sync.WeakInstancesTracker<K,I>
- Type Parameters:
K- the key typeI- the instances type
public class WeakInstancesTracker<K,I>
extends java.lang.Object
A thin wrapper for InstancesTracker, which wraps the key with weak references
to the key.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classWeakInstancesTracker.WeakRefA wrapper for WeakReference that also implement the Instances.KeyFinalizer interface, so that a key is held as a strong reference until it has been finalized -
Constructor Summary
Constructors Constructor Description WeakInstancesTracker(java.lang.Class<K> keyType, java.lang.Class<I> instanceType, Lambda1<K,I> constructLambda)Instantiates a new Weak instances tracker.WeakInstancesTracker(Type<K> keyType, Type<I> instanceType, Lambda1<K,I> constructLambda)Instantiates a new Weak instances tracker. -
Method Summary
Modifier and Type Method Description IconstructWith(K key, Lambda1<K,I> customLambda)Wraps InstancesTracker.constructWithIget(K key)Returns the instance associated with the provided keyjava.util.List<I>get(Lambda1<I,java.lang.Boolean> filter)Wraps InstancesTracker.getjava.util.List<I>get(Lambda1<I,java.lang.Boolean> filter, int limit)Wraps InstancesTracker.getjava.util.Set<I>getInstances()Wraps InstancesTracker.getInstancesjava.util.Set<K>getKeysFor(I instance)Wraps InstancesTracker.getKeysForIgetOrConstruct(K key)Wraps InstancesTracker.getOrConstructIgetOrConstructWith(K key, Lambda1<K,I> lambda)Wraps InstancesTracker.getOrConstructWithjava.util.Set<K>keySet()A view of the keyset for this WeakInstancesTracker.Iput(K key, I instance)Wraps InstancesTracker.putIremove(K key)Wraps InstancesTracker.remove
-
Constructor Details
-
WeakInstancesTracker
public WeakInstancesTracker(java.lang.Class<K> keyType, java.lang.Class<I> instanceType, Lambda1<K,I> constructLambda)Instantiates a new Weak instances tracker.- Parameters:
keyType- the key typeinstanceType- the instance typeconstructLambda- the construct lambda
-
WeakInstancesTracker
Instantiates a new Weak instances tracker.- Parameters:
keyType- the key typeinstanceType- the instance typeconstructLambda- the construct lambda
-
-
Method Details
-
get
Returns the instance associated with the provided key- Parameters:
key- the key- Returns:
- the instance
-
getOrConstruct
Wraps InstancesTracker.getOrConstruct- Parameters:
key- the key- Returns:
- the instance
-
getOrConstructWith
Wraps InstancesTracker.getOrConstructWith- Parameters:
key- the keylambda- the construct lambda- Returns:
- the instance
-
put
Wraps InstancesTracker.put- Parameters:
key- the keyinstance- the instance to put- Returns:
- any displaced instance
-
constructWith
Wraps InstancesTracker.constructWith- Parameters:
key- the keycustomLambda- the custom construct lambda- Returns:
- the instance associated with the key at the time this returns
-
remove
Wraps InstancesTracker.remove- Parameters:
key- the key- Returns:
- the instance that was previously associated with the key
-
getKeysFor
Wraps InstancesTracker.getKeysFor- Parameters:
instance- the instance- Returns:
- the keys that previously pointed to the provided instance
-
keySet
A view of the keyset for this WeakInstancesTracker. Wraps InstancesTracker.keySet- Returns:
- the set
-
get
Wraps InstancesTracker.get- Parameters:
filter- the filter- Returns:
- the list
-
get
Wraps InstancesTracker.get- Parameters:
filter- the filterlimit- the limit- Returns:
- the list
-
getInstances
Wraps InstancesTracker.getInstances- Returns:
- the instances
-