2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.nb.rfc8040.streams;
10 import static java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.AbstractRegistration;
16 * A single subscriber to an {@link AbstractStream}.
18 final class Subscriber<T> extends AbstractRegistration {
19 private final @NonNull RestconfStream<T> stream;
20 private final @NonNull StreamSessionHandler handler;
21 private final @NonNull EventFormatter<T> formatter;
23 Subscriber(final RestconfStream<T> stream, final StreamSessionHandler handler, final EventFormatter<T> formatter) {
24 this.stream = requireNonNull(stream);
25 this.handler = requireNonNull(handler);
26 this.formatter = requireNonNull(formatter);
29 @NonNull EventFormatter<T> formatter() {
33 @NonNull StreamSessionHandler handler() {
38 protected void removeRegistration() {
39 stream.removeSubscriber(this);