Package io.permazen.kv.simple
Class SimpleKVImplementation
java.lang.Object
io.permazen.kv.simple.SimpleKVImplementation
- All Implemented Interfaces:
KVImplementation<SimpleKVImplementation.Config>
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addOptions
(joptsimple.OptionParser parser) Add implementation-specific command line options.protected void
addSimpleOptions
(joptsimple.OptionParser parser, joptsimple.OptionSpec<?> enablingOption, String prefix) protected void
applySimpleOptions
(joptsimple.OptionSet options, SimpleKVImplementation.Config config) buildConfig
(joptsimple.OptionSet options) Build a configuration from implementation-specific command line options, if any were given.createKVDatabase
(SimpleKVImplementation.Config config, KVDatabase kvdb, AtomicKVStore kvstore) Create anKVDatabase
using the specified configuration.Generate a short, human-readable description of theKVDatabase
instance configured as given.boolean
Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.boolean
Determine whether this instance'sKVDatabase
implementation requires an underlyingAtomicKVStore
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.permazen.kv.KVImplementation
createAtomicKVStore, getConfigType, providesAtomicKVStore, requiresKVDatabase
-
Constructor Details
-
SimpleKVImplementation
public SimpleKVImplementation()
-
-
Method Details
-
addOptions
public void addOptions(joptsimple.OptionParser parser) Description copied from interface:KVImplementation
Add implementation-specific command line options.All of the added options must be optional, because multiple key/value implementations will be available when the command line is parsed, and the presence of implementation-specific options determines which one(s) are chosen.
- Parameters:
parser
- command line flag parser
-
buildConfig
Description copied from interface:KVImplementation
Build a configuration from implementation-specific command line options, if any were given.If none of this implementation's options were provided, then this method must return null.
- Parameters:
options
- parsed command line options- Returns:
- corresponding configuration, or null if this implementation was not configured
-
providesKVDatabase
Description copied from interface:KVImplementation
Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if this instance can create an
KVDatabase
-
createKVDatabase
public KVDatabase createKVDatabase(SimpleKVImplementation.Config config, KVDatabase kvdb, AtomicKVStore kvstore) Description copied from interface:KVImplementation
Create anKVDatabase
using the specified configuration.The implementation in
KVImplementation
always throwsUnsupportedOperationException
.- Parameters:
config
- implementation configuration returned bybuildConfig()
kvdb
- requiredKVDatabase
; will be null unlessKVImplementation.requiresKVDatabase(C)
returned truekvstore
- requiredAtomicKVStore
; will be null unlessKVImplementation.requiresAtomicKVStore(C)
returned true- Returns:
- new
KVDatabase
instance
-
requiresAtomicKVStore
Description copied from interface:KVImplementation
Determine whether this instance'sKVDatabase
implementation requires an underlyingAtomicKVStore
.This method and
requiresKVDatabase()
may not both return true.The implementation in
KVImplementation
return false.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- true if the implementation relies on an underlying
AtomicKVStore
-
getDescription
Description copied from interface:KVImplementation
Generate a short, human-readable description of theKVDatabase
instance configured as given.- Parameters:
config
- implementation configuration returned bybuildConfig()
- Returns:
- human-readable description
-
addSimpleOptions
protected void addSimpleOptions(joptsimple.OptionParser parser, joptsimple.OptionSpec<?> enablingOption, String prefix) -
applySimpleOptions
protected void applySimpleOptions(joptsimple.OptionSet options, SimpleKVImplementation.Config config)
-