Record Class FormatSpec

java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.spi.FormatSpec
Record Components:
format - logical format name (e.g. "csv", "tsv", "parquet")
extensions - file extensions with leading dot (e.g. ".csv", ".parquet")

public record FormatSpec(String format, Set<String> extensions) extends Record
Describes a file format this plugin provides: a logical format name and the file extensions that select it.

The format name must match a key in the map returned by DataSourcePlugin.formatReaders(org.elasticsearch.common.settings.Settings). Multiple extensions may map to the same format (e.g. .ndjson, .jsonl, .json all select "ndjson"), but each extension should map to exactly one format across all plugins.

Example:

Set.of(
    new FormatSpec("csv",  Set.of(".csv")),
    new FormatSpec("tsv",  Set.of(".tsv"))
)
  • Constructor Details

    • FormatSpec

      public FormatSpec(String format, Set<String> extensions)
      Creates an instance of a FormatSpec record class.
      Parameters:
      format - the value for the format record component
      extensions - the value for the extensions record component
  • Method Details

    • of

      public static FormatSpec of(String format, String extension)
      Convenience factory for the common single-extension case.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • format

      public String format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • extensions

      public Set<String> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component