Record Class ReadColumn<T>

java.lang.Object
java.lang.Record
io.github.dornol.excelkit.core.ReadColumn<T>
Type Parameters:
T - the row data type
Record Components:
headerName - optional header name for name-based column matching (null for positional/index)
columnIndex - explicit 0-based column index (-1 for positional/name-based)
setter - the setter function to bind a column value to a field
isRequired - if true, blank/empty cells will produce a validation error

public record ReadColumn<T>(@Nullable String headerName, int columnIndex, BiConsumer<T,CellData> setter, boolean isRequired) extends Record
Represents a single column binding for reading (Excel or CSV).

Supports three matching modes:

  • Positional (default) — matched by insertion order
  • Name-based — matched by header name via headerName
  • Index-based — matched by explicit column index via columnIndex
Since:
0.14.0
  • Constructor Details

    • ReadColumn

      public ReadColumn(BiConsumer<T,CellData> setter)
      Creates a positional column binding (matched by column index order).
      Parameters:
      setter - the setter function
    • ReadColumn

      public ReadColumn(String headerName, BiConsumer<T,CellData> setter)
      Creates a name-based column binding.
      Parameters:
      headerName - the header name to match
      setter - the setter function
    • ReadColumn

      public ReadColumn(@Nullable String headerName, int columnIndex, BiConsumer<T,CellData> setter)
      Creates a column binding with explicit index.
      Parameters:
      headerName - the header name (nullable)
      columnIndex - 0-based column index (-1 for positional/name-based)
      setter - the setter function
    • ReadColumn

      public ReadColumn(@Nullable String headerName, int columnIndex, BiConsumer<T,CellData> setter, boolean isRequired)
      Creates an instance of a ReadColumn record class.
      Parameters:
      headerName - the value for the headerName record component
      columnIndex - the value for the columnIndex record component
      setter - the value for the setter record component
      isRequired - the value for the isRequired record component
  • Method Details

    • required

      public ReadColumn<T> required()
      Returns a copy of this column marked as required. When a required column has a blank/empty cell value, the row will be marked as failed.
      Returns:
      a new ReadColumn with isRequired=true
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • headerName

      public @Nullable String headerName()
      Returns the value of the headerName record component.
      Returns:
      the value of the headerName record component
    • columnIndex

      public int columnIndex()
      Returns the value of the columnIndex record component.
      Returns:
      the value of the columnIndex record component
    • setter

      public BiConsumer<T,CellData> setter()
      Returns the value of the setter record component.
      Returns:
      the value of the setter record component
    • isRequired

      public boolean isRequired()
      Returns the value of the isRequired record component.
      Returns:
      the value of the isRequired record component