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

internal.sdmxdl.FunctionalListener Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta.13
Show newest version
package internal.sdmxdl;

import org.checkerframework.checker.nullness.qual.NonNull;
import sdmxdl.file.SdmxFileListener;
import sdmxdl.file.SdmxFileSource;
import sdmxdl.web.SdmxWebListener;
import sdmxdl.web.SdmxWebSource;

import java.util.Objects;
import java.util.function.BiConsumer;

@lombok.Builder
public final class FunctionalListener implements SdmxWebListener, SdmxFileListener {

    @lombok.NonNull
    @lombok.Builder.Default
    private final BiConsumer onWeb = FunctionalListener::doNothing;

    @lombok.NonNull
    @lombok.Builder.Default
    private final BiConsumer onFile = FunctionalListener::doNothing;

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public void onWebSourceEvent(@NonNull SdmxWebSource source, @NonNull String message) {
        Objects.requireNonNull(source);
        Objects.requireNonNull(message);
        onWeb.accept(source, message);
    }

    @Override
    public void onFileSourceEvent(@NonNull SdmxFileSource source, @NonNull String message) {
        Objects.requireNonNull(source);
        Objects.requireNonNull(message);
        onFile.accept(source, message);
    }

    @SuppressWarnings("EmptyMethod")
    private static void doNothing(Object source, Object message) {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy