@Override
    public byte[] fromConnectData(String topic, Schema schema, Object value) {
        if (schema != null && schema.type() != Type.BOOLEAN)
            throw new DataException("Invalid schema type for BooleanConverter: " + schema.type().toString());

        try {
            return serializer.serialize(topic, (Boolean) value);
        } catch (ClassCastException e) {
            throw new DataException("BooleanConverter is not compatible with objects of type " + value.getClass());
        }
    }
{@link Converter} and {@link HeaderConverter} implementation that supports serializing to and
deserializing from Boolean values.
<p>
When converting from bytes to Kafka Connect format, the converter will always return an optional
BOOLEAN schema.
connect/runtime/src/main/java/org/apache/kafka/connect/converters/BooleanConverter.java