B
- type of the builder itself; used to construct call chainsS
- type of the built storage@Internal
public abstract class StorageBuilder<B extends StorageBuilder<B,S>,S extends io.spine.server.storage.Storage>
extends java.lang.Object
Storage
implementations.
Aggregates all the common fields of the JDBC storages.
Each setter method returns an instance of the builder itself (this
).
Constructor and Description |
---|
StorageBuilder() |
Modifier and Type | Method and Description |
---|---|
S |
build()
Creates a new instance of the
Storage with respect to the preconditions. |
protected void |
checkPreconditions()
Checks the preconditions of the storage construction.
|
protected abstract S |
doBuild()
Builds a new instance of the
Storage . |
DataSourceWrapper |
getDataSource() |
protected abstract B |
getThis()
Returns current instance of
StorageBuilder . |
TypeMapping |
getTypeMapping() |
boolean |
isMultitenant() |
B |
setDataSource(DataSourceWrapper dataSource)
Sets the data source.
|
B |
setMultitenant(boolean multitenant)
Specifies the multitenant behavior.
|
B |
setTypeMapping(TypeMapping typeMapping)
Sets the type mapping schema.
|
public boolean isMultitenant()
public B setMultitenant(boolean multitenant)
multitenant
- determines if the storage is multitenant or notStorage.isMultitenant()
public DataSourceWrapper getDataSource()
public B setDataSource(DataSourceWrapper dataSource)
dataSource
- the DataSourceWrapper used by the storagepublic TypeMapping getTypeMapping()
public B setTypeMapping(TypeMapping typeMapping)
typeMapping
- the type mapping for the usage in queriespublic S build()
Storage
with respect to the preconditions.Storage
checkPreconditions()
protected void checkPreconditions() throws java.lang.IllegalStateException
Default implementation checks that the field dataSource
was set to a non-null value.
Override this method to modify these preconditions.
java.lang.IllegalStateException
- upon a precondition violationprotected abstract B getThis()
StorageBuilder
.
Used in setters to avoid extra unchecked casts.
StorageBuilder.this
referenceprotected abstract S doBuild()
Storage
.
The construction preconditions are checked before calling this method.
Storage
.