2 * Copyright (c) 2016 Cisco Systems, Inc. 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.listeners;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.VisibleForTesting;
13 import java.time.Instant;
14 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
17 * Features of query parameters part of both notifications.
19 abstract class AbstractQueryParams extends AbstractNotificationsData {
20 // FIXME: these should be final
21 private Instant startTime = null;
22 private Instant stopTime = null;
23 private boolean leafNodesOnly = false;
24 private boolean skipNotificationData = false;
27 public final Instant getStart() {
32 * Set query parameters for listener.
34 * @param startTime Start-time of getting notification.
35 * @param stopTime Stop-time of getting notification.
36 * @param filter Indicates which subset of all possible events are of interest.
37 * @param leafNodesOnly If TRUE, notifications will contain changes of leaf nodes only.
39 public abstract void setQueryParams(Instant startTime, Instant stopTime, String filter,
40 boolean leafNodesOnly, boolean skipNotificationData);
42 @SuppressWarnings("checkstyle:hiddenField")
43 final void setQueryParams(final Instant startTime, final Instant stopTime, final boolean leafNodesOnly,
44 final boolean skipNotificationData) {
45 this.startTime = requireNonNull(startTime);
46 this.stopTime = stopTime;
47 this.leafNodesOnly = leafNodesOnly;
48 this.skipNotificationData = skipNotificationData;
52 * Check whether this query should only notify about leaf node changes.
54 * @return true if this query should only notify about leaf node changes
56 boolean getLeafNodesOnly() {
61 * Check whether this query should notify changes without data.
63 * @return true if this query should notify about changes with data
65 public boolean isSkipNotificationData() {
66 return skipNotificationData;
69 @SuppressWarnings("checkstyle:IllegalCatch")
70 <T extends BaseListenerInterface> boolean checkStartStop(final Instant now, final T listener) {
71 if (stopTime != null) {
72 if (startTime.compareTo(now) < 0 && stopTime.compareTo(now) > 0) {
75 if (stopTime.compareTo(now) < 0) {
78 } catch (final Exception e) {
79 throw new RestconfDocumentedException("Problem with unregister listener." + e);
82 } else if (startTime != null) {
83 if (startTime.compareTo(now) < 0) {