Class CsvBindException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class CsvBindException extends OpenCsvException
CSV Bind Exception - Exception for CSV-to-object binding errors CSV绑定异常 - CSV到对象绑定错误异常

Thrown when a CSV row cannot be bound to a target object, for example due to type mismatches, missing required fields, or reflection failures.

当CSV行无法绑定到目标对象时抛出,例如类型不匹配、缺少必需字段或反射失败。

Usage Examples | 使用示例:

throw CsvBindException.of(MyRecord.class, "amount", cause);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
Since:
JDK 25, opencode-base-csv V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CsvBindException

      public CsvBindException(String message, Class<?> targetType, String fieldName)
      Constructs a bind exception with target type and field name (no cause) 构造带目标类型和字段名的绑定异常(无原因)
      Parameters:
      message - the detail message | 详细消息
      targetType - the target type | 目标类型
      fieldName - the field name | 字段名
    • CsvBindException

      public CsvBindException(String message, Class<?> targetType, String fieldName, Throwable cause)
      Constructs a bind exception with target type, field name, and cause 构造带目标类型、字段名和原因的绑定异常
      Parameters:
      message - the detail message | 详细消息
      targetType - the target type | 目标类型
      fieldName - the field name | 字段名
      cause - the cause | 原因
  • Method Details

    • getTargetType

      public Class<?> getTargetType()
      Gets the target type that binding failed for 获取绑定失败的目标类型
      Returns:
      the target type, or null | 目标类型,或null
    • getFieldName

      public String getFieldName()
      Gets the field name that caused the binding failure 获取导致绑定失败的字段名
      Returns:
      the field name, or null | 字段名,或null
    • of

      public static CsvBindException of(Class<?> type, String field, Throwable cause)
      Creates a bind exception for a specific type and field 为特定类型和字段创建绑定异常
      Parameters:
      type - the target type | 目标类型
      field - the field name | 字段名
      cause - the cause | 原因
      Returns:
      the exception | 异常