Class Schema
java.lang.Object
org.moeaframework.analysis.store.schema.Schema
A schema that defines the structure of a
DataStore
, specifically detailing the required fields, their types,
and order. This is useful for validation, ensuring the data being stored contains all required information.
If no fields are defined, this instead operates in schemaless mode, wherein such validations are skipped and the structure is inferred from the reference only. Fields are sorted according to their natural order.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Field<?>
get
(int index) Returns the field at the given index.Field<?>
Returns the field with the given name.Returns all fields defined by this schema in their designated order.int
hashCode()
boolean
Returnstrue
if schemaless or has no defined fields;false
otherwisestatic Schema
Constructs a schema with the given fields.Resolves the given reference according to this schema.static Schema
Constructs a schema without any defined fields (i.e., schemaless).int
size()
Returns the number of fields defined by this schema.toString()
void
updateManifest
(Manifest manifest) Updates the manifest with information about this schema.
-
Constructor Details
-
Schema
Constructs a schema with the given fields.- Parameters:
fields
- the fields, which if empty operates in schemaless mode
-
-
Method Details
-
size
public int size()Returns the number of fields defined by this schema.- Returns:
- the number of fields
-
get
Returns the field at the given index.- Parameters:
index
- the index- Returns:
- the field at the given index
- Throws:
IndexOutOfBoundsException
- if the index is out of bounds
-
get
Returns the field with the given name.- Parameters:
name
- the field name- Returns:
- the field with the given name
- Throws:
IllegalArgumentException
- if no such field exists
-
getFields
Returns all fields defined by this schema in their designated order.- Returns:
- the fields
-
resolve
Resolves the given reference according to this schema. This process validates that all required fields are defined and orders them per the schema.- Parameters:
reference
- the data reference- Returns:
- the resolved fields and values according to this schema
- Throws:
IllegalArgumentException
- if the reference did not satisfy the requirements of this schema
-
isSchemaless
public boolean isSchemaless()Returnstrue
if schemaless or has no defined fields;false
otherwise- Returns:
true
if schemaless;false
otherwise
-
updateManifest
Updates the manifest with information about this schema.- Parameters:
manifest
- the manifest
-
toString
-
hashCode
public int hashCode() -
equals
-
of
Constructs a schema with the given fields.- Parameters:
fields
- the fields- Returns:
- the schema
-
schemaless
Constructs a schema without any defined fields (i.e., schemaless).- Returns:
- the schema
-