Class ValueVenue<K,V>
java.lang.Object
io.github.projectunified.valuevenue.core.ValueVenue<K,V>
- Type Parameters:
K- type of the keyV- type of the generated value
Holds the values generated for each key.
Values are computed only when update(Object) is called for a key; get(Object) never
generates anything and returns an empty list until the key has been updated at least once.
Instances are safe for concurrent use; readers see either the values stored before or after an
update(Object) call, never a partially generated list.
-
Constructor Summary
ConstructorsConstructorDescriptionValueVenue(Function<K, List<V>> valueGenerator) Creates a venue whose keys are updated throughupdate(Object). -
Method Summary
-
Constructor Details
-
ValueVenue
Creates a venue whose keys are updated throughupdate(Object).- Parameters:
valueGenerator- generator invoked byupdate(Object)to compute the values of a key
-
-
Method Details
-
get
Returns the values stored for the key by the lastupdate(Object)call.- Parameters:
key- key to look up- Returns:
- read-only list of the stored values, empty if the key was never updated
-
update
Generates the values of the key and stores them, replacing any previous values.- Parameters:
key- key to regenerate
-