All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.apicurio.registry.serde.strategy.TopicIdStrategy Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package io.apicurio.registry.serde.strategy;

import io.apicurio.registry.resolver.ParsedSchema;
import io.apicurio.registry.resolver.data.Record;
import io.apicurio.registry.resolver.strategy.ArtifactReference;
import io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy;
import io.apicurio.registry.serde.data.SerdeMetadata;
import io.apicurio.registry.serde.data.SerdeRecord;

public class TopicIdStrategy implements ArtifactReferenceResolverStrategy {

    @Override
    public ArtifactReference artifactReference(Record data, ParsedSchema parsedSchema) {
        SerdeRecord kdata = (SerdeRecord) data;
        SerdeMetadata metadata = kdata.metadata();
        return ArtifactReference.builder().groupId(null)
                .artifactId(String.format("%s-%s", metadata.getTopic(), metadata.isKey() ? "key" : "value"))
                .build();
    }

    /**
     * @see io.apicurio.registry.serde.strategy.ArtifactResolverStrategy#loadSchema()
     */
    @Override
    public boolean loadSchema() {
        return false;
    }

}