Class FactMap<T extends @Nullable Object>

java.lang.Object
io.github.brantunger.unruly.api.FactMap<T>
Type Parameters:
T - The object/value type of the facts
All Implemented Interfaces:
FactStore<T>, Map<String,@Nullable FactReference<T>>

public class FactMap<T extends @Nullable Object> extends Object implements FactStore<T>, Map<String,@Nullable FactReference<T>>
The built-in FactStore: a map from each fact's name to its FactReference, backed by a HashMap.

Every way of adding a fact rejects a null name, and rejects a key that differs from the name of the fact stored under it, with IllegalArgumentException. That includes Map.Entry.setValue(V) on an entrySet() entry and replaceAll(java.util.function.BiFunction<? super java.lang.String, ? super io.github.brantunger.unruly.api.FactReference<T>, ? extends io.github.brantunger.unruly.api.FactReference<T>>). The varargs constructor also rejects two facts with the same name. getValue(java.lang.String) rejects a null name too, while get(java.lang.Object), containsKey(java.lang.Object) and remove(java.lang.Object) follow the Map contract: a null key is never stored, so they find nothing under it.

A FactMap is a Map as well as a FactStore, so a FactMap variable has every Map method. asMap() returns a read-only view of it.

equals, hashCode and toString follow the Map contract: two maps holding equal facts under the same names are equal, whatever their implementation.

Threads: not thread-safe, like the HashMap it wraps. Build one for each run, and don't change it while a run reads it.

See Also: