MINOR: Add Functional Interface annotation to interfaces used by Lambdas (#19234)

Adds the FunctionalInterface annotation to relevant Kafka Streams
classes. While this is not strictly required for Java, it's still best
practice and also useful for better integration with other JVM
languages, for example Clojure, to allow using these interfaces as
lambdas.

Reviewers: Matthias J. Sax <matthias@confluent.io>
This commit is contained in:
Thomas Gebert 2025-04-03 12:30:56 -04:00 committed by GitHub
parent f1bb29b93a
commit db4e74b46e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 26 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import java.util.Map;
* A callback interface that the user can implement to trigger custom actions when a commit request completes. The callback
* may be executed in any thread calling {@link Consumer#poll(java.time.Duration) poll()}.
*/
@FunctionalInterface
public interface OffsetCommitCallback {
/**

View File

@ -38,6 +38,7 @@ package org.apache.kafka.streams.kstream;
* @see SessionWindowedKStream#aggregate(Initializer, Aggregator, Merger, Materialized)
* @see Reducer
*/
@FunctionalInterface
public interface Aggregator<K, V, VAgg> {
/**

View File

@ -30,6 +30,7 @@ package org.apache.kafka.streams.kstream;
*
* @see KStream#foreach(ForeachAction)
*/
@FunctionalInterface
public interface ForeachAction<K, V> {
/**

View File

@ -30,6 +30,7 @@ package org.apache.kafka.streams.kstream;
* @see SessionWindowedKStream#aggregate(Initializer, Aggregator, Merger)
* @see SessionWindowedKStream#aggregate(Initializer, Aggregator, Merger, Materialized)
*/
@FunctionalInterface
public interface Initializer<VAgg> {
/**

View File

@ -44,6 +44,7 @@ import org.apache.kafka.streams.KeyValue;
* @see KTable#groupBy(KeyValueMapper, Grouped)
* @see KTable#toStream(KeyValueMapper)
*/
@FunctionalInterface
public interface KeyValueMapper<K, V, VR> {
/**

View File

@ -23,6 +23,7 @@ package org.apache.kafka.streams.kstream;
* @param <K> key type
* @param <V> aggregate value type
*/
@FunctionalInterface
public interface Merger<K, V> {
/**

View File

@ -31,6 +31,7 @@ import org.apache.kafka.streams.KeyValue;
* @see KTable#filter(Predicate)
* @see KTable#filterNot(Predicate)
*/
@FunctionalInterface
public interface Predicate<K, V> {
/**

View File

@ -36,6 +36,7 @@ import org.apache.kafka.streams.KeyValue;
* @see SessionWindowedKStream#reduce(Reducer, Materialized)
* @see Aggregator
*/
@FunctionalInterface
public interface Reducer<V> {
/**

View File

@ -38,6 +38,7 @@ import java.util.function.Supplier;
* @deprecated Since 4.0. Use {@link org.apache.kafka.streams.processor.api.ProcessorSupplier api.ProcessorSupplier} instead.
*/
@Deprecated
@FunctionalInterface
public interface TransformerSupplier<K, V, R> extends ConnectedStoreProvider, Supplier<Transformer<K, V, R>> {
/**

View File

@ -40,6 +40,7 @@ package org.apache.kafka.streams.kstream;
* @see KTable#leftJoin(KTable, ValueJoiner)
* @see KTable#outerJoin(KTable, ValueJoiner)
*/
@FunctionalInterface
public interface ValueJoiner<V1, V2, VR> {
/**

View File

@ -44,6 +44,7 @@ package org.apache.kafka.streams.kstream;
* @see KStream#leftJoin(GlobalKTable, KeyValueMapper, ValueJoinerWithKey)
* @see KStream#leftJoin(GlobalKTable, KeyValueMapper, ValueJoinerWithKey, Named)
*/
@FunctionalInterface
public interface ValueJoinerWithKey<K1, V1, V2, VR> {
/**

View File

@ -37,6 +37,7 @@ import org.apache.kafka.streams.processor.api.FixedKeyProcessor;
* @see KTable#mapValues(ValueMapper)
* @see KTable#mapValues(ValueMapperWithKey)
*/
@FunctionalInterface
public interface ValueMapper<V, VR> {
/**

View File

@ -38,6 +38,7 @@ package org.apache.kafka.streams.kstream;
* @see KTable#mapValues(ValueMapperWithKey)
*/
@FunctionalInterface
public interface ValueMapperWithKey<K, V, VR> {
/**

View File

@ -36,6 +36,7 @@ import org.apache.kafka.streams.processor.api.FixedKeyProcessorSupplier;
* @deprecated Since 4.0. Use {@link FixedKeyProcessorSupplier} instead.
*/
@Deprecated
@FunctionalInterface
public interface ValueTransformerSupplier<V, VR> extends ConnectedStoreProvider {
/**

View File

@ -35,6 +35,7 @@ import java.util.function.Supplier;
* @see Transformer
* @see TransformerSupplier
*/
@FunctionalInterface
public interface ValueTransformerWithKeySupplier<K, V, VR> extends ConnectedStoreProvider, Supplier<ValueTransformerWithKey<K, V, VR>> {
/**

View File

@ -28,6 +28,7 @@ import java.util.Collection;
* It is expected that implementations of this class will not call the {@link StateRestoreCallback#restore(byte[],
* byte[])} method.
*/
@FunctionalInterface
public interface BatchingStateRestoreCallback extends StateRestoreCallback {
/**

View File

@ -23,6 +23,7 @@ import java.time.Duration;
*
* @see Punctuator
*/
@FunctionalInterface
public interface Cancellable {
/**

View File

@ -26,6 +26,7 @@ import java.time.Duration;
*
* @see Cancellable
*/
@FunctionalInterface
public interface Punctuator {
/**

View File

@ -20,6 +20,7 @@ package org.apache.kafka.streams.processor;
* Restoration logic for log-backed state stores upon restart,
* it takes one record at a time from the logs to apply to the restoring state.
*/
@FunctionalInterface
public interface StateRestoreCallback {
void restore(byte[] key, byte[] value);

View File

@ -50,6 +50,7 @@ import java.util.Set;
* org.apache.kafka.common.serialization.Serializer, StreamPartitioner, String...)
* @see Topology#addSink(String, String, StreamPartitioner, String...)
*/
@FunctionalInterface
public interface StreamPartitioner<K, V> {
/**

View File

@ -23,6 +23,7 @@ import org.apache.kafka.streams.kstream.KTable;
* An interface that allows the Kafka Streams framework to extract a timestamp from an instance of {@link ConsumerRecord}.
* The extracted timestamp is defined as milliseconds.
*/
@FunctionalInterface
public interface TimestampExtractor {
/**

View File

@ -19,6 +19,7 @@ package org.apache.kafka.streams.processor;
/**
* An interface that allows to dynamically determine the name of the Kafka topic to send at the sink node of the topology.
*/
@FunctionalInterface
public interface TopicNameExtractor<K, V> {
/**

View File

@ -29,6 +29,7 @@ import java.time.Duration;
* @param <VIn> the type of input values
* @param <VOut> the type of output values
*/
@FunctionalInterface
public interface FixedKeyProcessor<KIn, VIn, VOut> {
/**

View File

@ -30,6 +30,7 @@ import java.time.Duration;
* @param <KOut> the type of output keys
* @param <VOut> the type of output values
*/
@FunctionalInterface
public interface Processor<KIn, VIn, KOut, VOut> {
/**

View File

@ -24,6 +24,7 @@ package org.apache.kafka.streams.processor.api;
* To convert a {@link FixedKeyProcessorSupplier} instance into a {@link WrappedFixedKeyProcessorSupplier},
* use the {@link ProcessorWrapper#asWrappedFixedKey(FixedKeyProcessorSupplier)} method
*/
@FunctionalInterface
public interface WrappedFixedKeyProcessorSupplier<KIn, VIn, VOut> extends FixedKeyProcessorSupplier<KIn, VIn, VOut> {
}

View File

@ -24,6 +24,7 @@ package org.apache.kafka.streams.processor.api;
* To convert a {@link ProcessorSupplier} instance into a {@link WrappedProcessorSupplier},
* use the {@link ProcessorWrapper#asWrapped(ProcessorSupplier)} method
*/
@FunctionalInterface
public interface WrappedProcessorSupplier<KIn, VIn, KOut, VOut> extends ProcessorSupplier<KIn, VIn, KOut, VOut> {
}