Package io.github.dornol.excelkit.core
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 fieldisRequired- 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 Summary
ConstructorsConstructorDescriptionReadColumn(@Nullable String headerName, int columnIndex, BiConsumer<T, CellData> setter) Creates a column binding with explicit index.ReadColumn(@Nullable String headerName, int columnIndex, BiConsumer<T, CellData> setter, boolean isRequired) Creates an instance of aReadColumnrecord class.ReadColumn(String headerName, BiConsumer<T, CellData> setter) Creates a name-based column binding.ReadColumn(BiConsumer<T, CellData> setter) Creates a positional column binding (matched by column index order). -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecolumnIndexrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable StringReturns the value of theheaderNamerecord component.booleanReturns the value of theisRequiredrecord component.required()Returns a copy of this column marked as required.setter()Returns the value of thesetterrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ReadColumn
Creates a positional column binding (matched by column index order).- Parameters:
setter- the setter function
-
ReadColumn
Creates a name-based column binding.- Parameters:
headerName- the header name to matchsetter- the setter function
-
ReadColumn
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 aReadColumnrecord class.- Parameters:
headerName- the value for theheaderNamerecord componentcolumnIndex- the value for thecolumnIndexrecord componentsetter- the value for thesetterrecord componentisRequired- the value for theisRequiredrecord component
-
-
Method Details
-
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
headerName
Returns the value of theheaderNamerecord component.- Returns:
- the value of the
headerNamerecord component
-
columnIndex
public int columnIndex()Returns the value of thecolumnIndexrecord component.- Returns:
- the value of the
columnIndexrecord component
-
setter
Returns the value of thesetterrecord component.- Returns:
- the value of the
setterrecord component
-
isRequired
public boolean isRequired()Returns the value of theisRequiredrecord component.- Returns:
- the value of the
isRequiredrecord component
-