Class TruncateStrings

java.lang.Object
io.debezium.relational.mapping.TruncateStrings
All Implemented Interfaces:
ColumnMapper

public class TruncateStrings extends Object implements ColumnMapper
A ColumnMapper implementation that ensures that string values longer than a specified length will be truncated.
Author:
Randall Hauch
  • Field Details

  • Constructor Details

    • TruncateStrings

      public TruncateStrings(int maxLength)
      Create a ColumnMapper that truncates string values to a maximum length.
      Parameters:
      maxLength - the maximum number of characters allowed in values
      Throws:
      IllegalArgumentException - if the maxLength is not positive
  • Method Details

    • create

      public ValueConverter create(Column column)
      Description copied from interface: ColumnMapper
      Create for the given column a function that maps values.
      Specified by:
      create in interface ColumnMapper
      Parameters:
      column - the column description; never null
      Returns:
      the function that converts the value; may be null
    • alterFieldSchema

      public void alterFieldSchema(Column column, org.apache.kafka.connect.data.SchemaBuilder schemaBuilder)
      Description copied from interface: ColumnMapper
      Optionally annotate the schema with properties to better capture the mapping behavior.
      Specified by:
      alterFieldSchema in interface ColumnMapper
      Parameters:
      column - the column definition; never null
      schemaBuilder - the builder for the Field's schema; never null
    • isTruncationPossible

      protected boolean isTruncationPossible(Column column)