Package org.apache.avro

# Interface SchemaFormatterFactory

All Known Implementing Classes:
  `CanonicalSchemaFormatterFactory`, `JsonSchemaFormatterFactory`

public interface SchemaFormatterFactory
Service Provider Interface (SPI) for `SchemaFormatter`.

Notes to implementers:

- Implementations are located using a `ServiceLoader`. See that class for details.
- Implementing classes should either be named `<format>SchemaFormatterFactory` (where the format is alphanumeric), or implement `formatName()`.
- Implement at least `getDefaultFormatter()`; use it to call `getFormatterForVariant(String)` if the format supports multiple variants.
- Example implementations are `JsonSchemaFormatterFactory` and `CanonicalSchemaFormatterFactory`

See Also:
  - `ServiceLoader`

## Method Summary

Modifier and Type
Method
Description
`default String`
`formatName()`
Return the name of the format this formatter factory supports.
`SchemaFormatter`
`getDefaultFormatter()`
Get the default formatter for this schema format.
`default SchemaFormatter`
`getFormatterForVariant(String variantName)`
Get a formatter for the specified schema format variant, if multiple variants are supported.

## Method Details

### formatName

default String formatName()
Return the name of the format this formatter factory supports.

The default implementation returns the lowercase prefix of the implementing class if it is named `<format>SchemaFormatterFactory`. That is, if the implementing class is named `some.package.JsonSchemaFormatterFactory`, it returns: "json"

Returns:
  the name of the format

### getDefaultFormatter

SchemaFormatter getDefaultFormatter()
Get the default formatter for this schema format. Instances should be thread-safe, as they may be cached.

Implementations should either return the only formatter for this format, or call `getFormatterForVariant(String)` with the default variant and implement that method as well.

Returns:
  the default formatter for this schema format

### getFormatterForVariant

default SchemaFormatter getFormatterForVariant(String variantName)
Get a formatter for the specified schema format variant, if multiple variants are supported. Instances should be thread-safe, as they may be cached.

Parameters:
  `variantName` - the name of the format variant (lower case), if specified
Returns:
  if the factory supports the format, a schema writer; `null` otherwise