Package io.permazen.core
Class SchemaBundle
java.lang.Object
io.permazen.core.SchemaBundle
Reflects the Schema table currently recorded in a
Database
as seen by a particular Transaction
.
This includes any Schema
s that may have been added or deleted during the transaction.
This class also captures the current Storage ID table.
Instances are immutable and thread safe.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Constructor Summary
ConstructorDescriptionSchemaBundle
(SchemaBundle.Encoded encoded, EncodingRegistry encodingRegistry) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the encoded form of this instance.Get theEncodingRegistry
associated with this instance.getSchema
(int schemaIndex) Get theSchema
in this bundle with the given schema index.Get theSchema
in this bundle having the given schema ID.Get all of the storage ID's in this bundle with their correspondingSchemaId
's.Get all of the schemas in this bundle keyed bySchemaId
.Get all of the schemas in this bundle keyed by schema index.int
getStorageId
(SchemaId schemaId) Get the storage ID corresponding to the given schema ID.withSchemaAdded
(int schemaIndex, SchemaModel schemaModel) Build anSchemaBundle.Encoded
instance with the specified schema added.withSchemaRemoved
(SchemaId schemaId) Build anSchemaBundle.Encoded
instance with the specified schema removed.
-
Constructor Details
-
SchemaBundle
Constructor.- Parameters:
encoded
- encoded schema and storage ID tablesencodingRegistry
- registry for simple field encodings- Throws:
InconsistentDatabaseException
- if the encoded data is invalidIllegalArgumentException
- if either parameter is null
-
-
Method Details
-
getEncoded
Get the encoded form of this instance.- Returns:
- encoded schema bundle
-
getEncodingRegistry
Get theEncodingRegistry
associated with this instance.- Returns:
- encoding registry
-
getSchemasBySchemaIndex
Get all of the schemas in this bundle keyed by schema index.- Returns:
- unmodifiable map of
Schema
s indexed by schema index
-
getSchemasBySchemaId
Get all of the schemas in this bundle keyed bySchemaId
.- Returns:
- unmodifiable map of
Schema
s indexed by schema ID
-
getSchema
Get theSchema
in this bundle with the given schema index.- Parameters:
schemaIndex
- schema index- Returns:
- corresponding schema
- Throws:
IllegalArgumentException
- ifschemaIndex
is invalid or unknown
-
getSchema
Get theSchema
in this bundle having the given schema ID.- Parameters:
schemaId
- schema structure ID- Returns:
- schema with ID
schemaId
- Throws:
IllegalArgumentException
- ifschemaId
is not known
-
getSchemaIdsByStorageId
Get all of the storage ID's in this bundle with their correspondingSchemaId
's.- Returns:
- unmodifiable map from storage ID to
SchemaId
-
getStorageId
Get the storage ID corresponding to the given schema ID.- Parameters:
schemaId
- schema structure ID- Returns:
- associated storage ID
- Throws:
IllegalArgumentException
- ifschemaId
is not known
-
withSchemaAdded
Build anSchemaBundle.Encoded
instance with the specified schema added.Any required storage ID assignments will be added automatically.
- Parameters:
schemaIndex
- schema table index at which to add the schema or zero for next availableschemaModel
- the new schema to add- Throws:
IllegalArgumentException
- if the schema already existsSchemaMismatchException
- ifschemaModel
has any explicit storage ID assignments that conflict with other schemas in this bundleSchemaMismatchException
- ifschemaIndex
is non-zero and some schema already exists at that indexIllegalArgumentException
- ifschemaModel
is not locked downIllegalArgumentException
- ifschemaModel
does not validateIllegalArgumentException
- ifschemaModel
is nullIllegalArgumentException
- ifschemaIndex
is negative
-
withSchemaRemoved
Build anSchemaBundle.Encoded
instance with the specified schema removed.Any obsolete storage ID assignments will be removed automatically.
- Parameters:
schemaId
- ID of the schema to remove- Throws:
IllegalArgumentException
- ifschemaId
is nullIllegalArgumentException
- if the schema does not exist
-