Repository: apache/kafka
File: streams/src/main/java/org/apache/kafka/streams/kstream/internals/KeyValueStoreMaterializer.java (Java)

Code before:
 * Materializes a key-value store as either a {@link TimestampedKeyValueStoreBuilder} or a
 * {@link VersionedKeyValueStoreBuilder} depending on whether the store is versioned or not.
 */
public class KeyValueStoreMaterializer<K, V> extends MaterializedStoreFactory<K, V, KeyValueStore<Bytes, byte[]>> {
    private static final Logger LOG = LoggerFactory.getLogger(KeyValueStoreMaterializer.class);

    public KeyValueStoreMaterializer(
            final MaterializedInternal<K, V, KeyValueStore<Bytes, byte[]>> materialized
    ) {
        super(materialized);
    }

    @Override
    public StoreBuilder<?> builder() {
        final DslStoreFormat storeFormat = dslStoreFormat() != null ? dslStoreFormat() : DslStoreFormat.TIMESTAMPED;
        final KeyValueBytesStoreSupplier supplier = materialized.storeSupplier() == null
                ? dslStoreSuppliers().keyValueStore(new DslKeyValueParams(materialized.storeName(), storeFormat))
                : (KeyValueBytesStoreSupplier) materialized.storeSupplier();

        final StoreBuilder<?> builder;
        if (supplier instanceof VersionedBytesStoreSupplier) {
            builder = Stores.versionedKeyValueStoreBuilder(
                    (VersionedBytesStoreSupplier) supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        } else if (storeFormat.equals(DslStoreFormat.HEADERS)) {
            builder = Stores.timestampedKeyValueStoreBuilderWithHeaders(
                    supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        } else if (storeFormat.equals(DslStoreFormat.TIMESTAMPED)) {
            builder = Stores.timestampedKeyValueStoreBuilder(
                    supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        } else if (storeFormat.equals(DslStoreFormat.PLAIN)) {
            builder = Stores.keyValueStoreBuilder(
                supplier,
                materialized.keySerde(),
                materialized.valueSerde());
        } else {
            throw new IllegalArgumentException("Unsupported store format: " + storeFormat);
        }

        if (materialized.loggingEnabled()) {
            builder.withLoggingEnabled(materialized.logConfig());
        } else {
            builder.withLoggingDisabled();
        }

        if (materialized.cachingEnabled()) {

Review comment (suggestion):
```suggestion
        } else if (storeFormat == DslStoreFormat.HEADERS) {
```

Code after:
 * Materializes a key-value store as either a {@link TimestampedKeyValueStoreBuilder} or a
 * {@link VersionedKeyValueStoreBuilder} depending on whether the store is versioned or not.
 */
public class KeyValueStoreMaterializer<K, V> extends MaterializedStoreFactory<K, V, KeyValueStore<Bytes, byte[]>> {
    private static final Logger LOG = LoggerFactory.getLogger(KeyValueStoreMaterializer.class);

    public KeyValueStoreMaterializer(
            final MaterializedInternal<K, V, KeyValueStore<Bytes, byte[]>> materialized
    ) {
        super(materialized);
    }

    @Override
    public StoreBuilder<?> builder() {
        final DslStoreFormat storeFormat = dslStoreFormat() == null ? DslStoreFormat.TIMESTAMPED : DslStoreFormat.HEADERS;
        final KeyValueBytesStoreSupplier supplier = materialized.storeSupplier() == null
                ? dslStoreSuppliers().keyValueStore(new DslKeyValueParams(materialized.storeName(), storeFormat))
                : (KeyValueBytesStoreSupplier) materialized.storeSupplier();

        final StoreBuilder<?> builder;
        if (supplier instanceof VersionedBytesStoreSupplier) {
            builder = Stores.versionedKeyValueStoreBuilder(
                    (VersionedBytesStoreSupplier) supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
        } else {
            if (storeFormat == DslStoreFormat.HEADERS) {
                builder = Stores.timestampedKeyValueStoreBuilderWithHeaders(
                    supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
            } else {
                builder = Stores.timestampedKeyValueStoreBuilder(
                    supplier,
                    materialized.keySerde(),
                    materialized.valueSerde());
            }
        }

        if (materialized.loggingEnabled()) {
            builder.withLoggingEnabled(materialized.logConfig());
        } else {
            builder.withLoggingDisabled();
        }

        if (materialized.cachingEnabled()) {
            if (builder instanceof VersionedKeyValueStoreBuilder) {
                LOG.info("Not enabling caching for store '{}' as versioned stores do not support caching.", supplier.name());
            } else {
                builder.withCachingEnabled();
            }