K - The key typepublic class SimpleRegionProvider<K extends IKey<K>> extends java.lang.Object implements IRegionProvider<K>
| Modifier and Type | Class and Description |
|---|---|
static interface |
SimpleRegionProvider.RegionExistsPredicate<K extends IKey<K>> |
static interface |
SimpleRegionProvider.RegionFactory<K extends IKey<K>> |
| Constructor and Description |
|---|
SimpleRegionProvider(IKeyProvider<K> keyProvider,
java.nio.file.Path directory,
SimpleRegionProvider.RegionFactory<K> regionBuilder,
SimpleRegionProvider.RegionExistsPredicate<K> regionExists) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static <K extends IKey<K>> |
createDefault(IKeyProvider<K> keyProvider,
java.nio.file.Path directory,
int sectorSize) |
void |
forAllRegions(CheckedBiConsumer<RegionKey,? super IRegion<K>,java.io.IOException> consumer)
Calls the given consumer for all existing region names.
|
void |
forExistingRegion(K key,
CheckedConsumer<? super IRegion<K>,java.io.IOException> consumer)
Calls the given function with region at that location and returns value from that function..
|
void |
forRegion(K key,
CheckedConsumer<? super IRegion<K>,java.io.IOException> consumer)
Calls the given consumer with region at that location.
|
<R> java.util.Optional<R> |
fromExistingRegion(K key,
CheckedFunction<? super IRegion<K>,R,java.io.IOException> func)
Calls the given consumer with region at that location.
|
<R> R |
fromRegion(K key,
CheckedFunction<? super IRegion<K>,R,java.io.IOException> func)
Calls the given function with region at that location and returns value from that function.
|
java.util.Optional<IRegion<K>> |
getExistingRegion(K key)
Gets an IRegion at a given region key, creates new one if it doesn't exist.
|
IRegion<K> |
getRegion(K key)
Gets an IRegion at a given region key, or create one if it does not exist.
|
public SimpleRegionProvider(IKeyProvider<K> keyProvider, java.nio.file.Path directory, SimpleRegionProvider.RegionFactory<K> regionBuilder, SimpleRegionProvider.RegionExistsPredicate<K> regionExists)
public <R> java.util.Optional<R> fromExistingRegion(K key, CheckedFunction<? super IRegion<K>,R,java.io.IOException> func) throws java.io.IOException
IRegionProviderfromExistingRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionregionKey if it existsjava.io.IOExceptionpublic <R> R fromRegion(K key, CheckedFunction<? super IRegion<K>,R,java.io.IOException> func) throws java.io.IOException
IRegionProviderfromRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionjava.io.IOExceptionpublic void forRegion(K key, CheckedConsumer<? super IRegion<K>,java.io.IOException> consumer) throws java.io.IOException
IRegionProviderforRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionconsumer - Consumer that accepts the IRegionjava.io.IOExceptionpublic void forExistingRegion(K key, CheckedConsumer<? super IRegion<K>,java.io.IOException> consumer) throws java.io.IOException
IRegionProviderforExistingRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionconsumer - Accepts the given region, if it already existsjava.io.IOExceptionpublic IRegion<K> getRegion(K key) throws java.io.IOException
IRegionProvidergetRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionregionKeyjava.io.IOExceptionpublic java.util.Optional<IRegion<K>> getExistingRegion(K key) throws java.io.IOException
IRegionProvidergetExistingRegion in interface IRegionProvider<K extends IKey<K>>key - The key for the IRegionregionKey if it existsjava.io.IOExceptionpublic void forAllRegions(CheckedBiConsumer<RegionKey,? super IRegion<K>,java.io.IOException> consumer) throws java.io.IOException
IRegionProviderforAllRegions in interface IRegionProvider<K extends IKey<K>>java.io.IOExceptionpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic static <K extends IKey<K>> SimpleRegionProvider<K> createDefault(IKeyProvider<K> keyProvider, java.nio.file.Path directory, int sectorSize)