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

bt.net.DelegatingMessageReaderWriter Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package bt.net;

import bt.protocol.Message;

import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;

class DelegatingMessageReaderWriter implements MessageReaderWriter {

    private final Supplier reader;
    private final Consumer writer;

    public DelegatingMessageReaderWriter(Supplier reader, Consumer writer) {
        this.reader = reader;
        this.writer = writer;
    }

    @Override
    public Optional readMessage() {
        return Optional.ofNullable(reader.get());
    }

    @Override
    public void writeMessage(Message message) {
        writer.accept(message);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy