
io.debezium.serde.DebeziumSerdes Maven / Gradle / Ivy
/*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.serde;
import org.apache.kafka.common.serialization.Serde;
import io.debezium.common.annotation.Incubating;
import io.debezium.serde.json.JsonSerde;
/**
* A factory class for Debezium provided serializers/deserializers.
*
* @author Jiri Pechanec
*
*/
@Incubating
public class DebeziumSerdes {
/**
* Provides a {@link Serde} implementation that maps JSON Debezium change events into a {@code T} Java object.
* When used as key deserializer, then the key field(s) are mapped into a corresponding Java object.
* When used as value deserializer, its behaviour is driven by the {@code from.field} config option:
*
*
* - not set: maps complete message envelope
* - {@code before} or {@code after}: extracts the given field from the envelope and maps it
*
* If schema is enabled then the serde will extract the {@code payload} field to get the envelope and apply
* the rules above.
*
* @param type to which JSON is mapped
* @param objectType type to which JSON is mapped
* @return serializer/deserializer to convert JSON to/from Java class
*/
public static Serde payloadJson(Class objectType) {
return new JsonSerde<>(objectType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy