# Class DefaultRecordSchema

Object
DefaultRecordSchema

All Implemented Interfaces:
  `Serializable, RecordSchema`

public final class DefaultRecordSchema extends Object implements RecordSchema, Serializable
A factory for creating `RecordType` instances.
Possible future change: This class is derived from ISO 19103:2005. The record attributes and methods have been modified in ISO 19103:2015, then all classes related to records have been fully removed in ISO 19103:2024. The implication for Apache SIS has not yet been determined. In the meantime, this class should be considered as merely a factory of `DefaultRecordType` instances.

## Thread safety

The same `DefaultRecordSchema` instance can be safely used by many threads without synchronization on the part of the caller if the `NameFactory` given to the constructor is also thread-safe. Subclasses should make sure that any overridden methods remain safe to call from multiple threads.

Since:
  0.5
See Also:
  - `DefaultRecordType`
  - `DefaultRecord`
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultRecordSchema(CharSequence schemaName)`
  Creates a new schema of the given name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DefaultRecordType`
  `createRecordType(CharSequence typeName, Map<CharSequence, Class<?>> fields)`
  Creates a new record type of the given name, which will contain the given fields.
  `TypeName`
  `createRecordTypeName(CharSequence typeName)`
  Creates the name of a record.
  `Map<TypeName, RecordType>`
  `getDescription()`
  Returns the dictionary of all (name, record type) pairs in this schema.
  `LocalName`
  `getSchemaName()`
  Returns the schema name.
  `RecordType`
  `locate(TypeName name)`
  Returns the record type for the given name.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### DefaultRecordSchema

    public DefaultRecordSchema(CharSequence schemaName)
    Creates a new schema of the given name.
    Parameters:
      `schemaName` - the name of the new schema.
    Since:
      1.6

- ## Method Details

  - ### getSchemaName

    public LocalName getSchemaName()
    Returns the schema name.
    Specified by:
      `getSchemaName` in interface `RecordSchema`
    Returns:
      the schema name.

  - ### createRecordTypeName

    public TypeName createRecordTypeName(CharSequence typeName)
    Creates the name of a record.
    Parameters:
      `typeName` - name of the record type to create.
    Returns:
      name of a record type.
    Since:
      1.3

  - ### createRecordType

    public DefaultRecordType createRecordType(CharSequence typeName, Map<CharSequence, Class<?>> fields) throws IllegalArgumentException
    Creates a new record type of the given name, which will contain the given fields. Fields are declared in iteration order.
    Parameters:
      `typeName` - name of the record type to create.
      `fields` - the name of each record field, together with the expected value types.
    Returns:
      a record type of the given name and fields.
    Throws:
      `IllegalArgumentException` - if a record already exists for the given name but with different fields.

  - ### getDescription

    public Map<TypeName, RecordType> getDescription()
    Returns the dictionary of all (name, record type) pairs in this schema.
    Specified by:
      `getDescription` in interface `RecordSchema`
    Returns:
      all (name, record type) pairs in this schema.

  - ### locate

    public RecordType locate(TypeName name)
    Returns the record type for the given name. If the type name is not defined within this schema, then this method returns `null`.
    Specified by:
      `locate` in interface `RecordSchema`
    Parameters:
      `name` - the name of the type to lookup.
    Returns:
      the type for the given name, or `null` if none.