Package org.apache.avro
Interface SchemaFormatterFactory
- All Known Implementing Classes:
CanonicalSchemaFormatterFactory,IdlSchemaFormatterFactory,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 implementformatName(). - Implement at least
getDefaultFormatter(); use it to callgetFormatterForVariant(String)if the format supports multiple variants. - Example implementations are
JsonSchemaFormatterFactoryandCanonicalSchemaFormatterFactory
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringReturn the name of the format this formatter factory supports.Get the default formatter for this schema format.default SchemaFormattergetFormatterForVariant(String variantName) Get a formatter for the specified schema format variant, if multiple variants are supported.
-
Method Details
-
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 namedsome.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
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;
nullotherwise
-