@PublicApi public class DataLoaderRegistry extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DataLoaderRegistry.Builder |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,DataLoader<?,?>> |
dataLoaders |
Constructor and Description |
---|
DataLoaderRegistry() |
Modifier and Type | Method and Description |
---|---|
DataLoaderRegistry |
combine(DataLoaderRegistry registry)
This will combine all the current data loaders in this registry and all the data loaders from the specified registry
and return a new combined registry
|
<K,V> DataLoader<K,V> |
computeIfAbsent(java.lang.String key,
java.util.function.Function<java.lang.String,DataLoader<?,?>> mappingFunction)
Computes a data loader if absent or return it if it was
already registered at that key.
|
void |
dispatchAll()
This will be called
DataLoader.dispatch() on each of the registered
DataLoader s |
int |
dispatchAllWithCount()
Similar to
dispatchAll() , this calls DataLoader.dispatch() on
each of the registered DataLoader s, but returns the number of dispatches. |
int |
dispatchDepth() |
<K,V> DataLoader<K,V> |
getDataLoader(java.lang.String key)
Returns the dataloader that was registered under the specified key
|
java.util.List<DataLoader<?,?>> |
getDataLoaders() |
java.util.Map<java.lang.String,DataLoader<?,?>> |
getDataLoadersMap() |
java.util.Set<java.lang.String> |
getKeys() |
Statistics |
getStatistics() |
static DataLoaderRegistry.Builder |
newRegistry() |
DataLoaderRegistry |
register(java.lang.String key,
DataLoader<?,?> dataLoader)
This will register a new dataloader
|
DataLoaderRegistry |
unregister(java.lang.String key)
This will unregister a new dataloader
|
protected final java.util.Map<java.lang.String,DataLoader<?,?>> dataLoaders
public DataLoaderRegistry register(java.lang.String key, DataLoader<?,?> dataLoader)
key
- the key to put the data loader underdataLoader
- the data loader to registerpublic <K,V> DataLoader<K,V> computeIfAbsent(java.lang.String key, java.util.function.Function<java.lang.String,DataLoader<?,?>> mappingFunction)
Note: The entire method invocation is performed atomically, so the function is applied at most once per key.
K
- the type of keysV
- the type of valueskey
- the key of the data loadermappingFunction
- the function to compute a data loaderpublic DataLoaderRegistry combine(DataLoaderRegistry registry)
registry
- the registry to combine into this registrypublic java.util.List<DataLoader<?,?>> getDataLoaders()
public java.util.Map<java.lang.String,DataLoader<?,?>> getDataLoadersMap()
public DataLoaderRegistry unregister(java.lang.String key)
key
- the key of the data loader to unregisterpublic <K,V> DataLoader<K,V> getDataLoader(java.lang.String key)
K
- the type of keysV
- the type of valueskey
- the key of the data loaderpublic java.util.Set<java.lang.String> getKeys()
public void dispatchAll()
DataLoader.dispatch()
on each of the registered
DataLoader
spublic int dispatchAllWithCount()
dispatchAll()
, this calls DataLoader.dispatch()
on
each of the registered DataLoader
s, but returns the number of dispatches.DataLoader
s.public int dispatchDepth()
DataLoader
spublic Statistics getStatistics()
public static DataLoaderRegistry.Builder newRegistry()
DataLoaderRegistry
s