2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
3 * Copyright (c) 2021 PANTHEON.tech, s.r.o.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.restconf.nb.rfc8040;
11 import static com.google.common.base.Preconditions.checkArgument;
13 import com.google.common.base.MoreObjects;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yangtools.concepts.Immutable;
19 * Parser and holder of query parameters from uriInfo for notifications.
21 public final class NotificationQueryParams implements Immutable {
22 private final StartTimeParameter startTime;
23 private final StopTimeParameter stopTime;
24 private final FilterParameter filter;
25 private final boolean skipNotificationData;
27 private NotificationQueryParams(final StartTimeParameter startTime, final StopTimeParameter stopTime,
28 final FilterParameter filter, final boolean skipNotificationData) {
29 this.startTime = startTime;
30 this.stopTime = stopTime;
32 this.skipNotificationData = skipNotificationData;
35 public static @NonNull NotificationQueryParams of(final StartTimeParameter startTime,
36 final StopTimeParameter stopTime, final FilterParameter filter, final boolean skipNotificationData) {
37 checkArgument(stopTime == null || startTime != null,
38 "Stop-time parameter has to be used with start-time parameter.");
39 return new NotificationQueryParams(startTime, stopTime, filter, skipNotificationData);
43 * Get start-time query parameter.
47 public @Nullable StartTimeParameter startTime() {
52 * Get stop-time query parameter.
56 public @Nullable StopTimeParameter stopTime() {
61 * Get filter query parameter.
65 public @Nullable FilterParameter filter() {
70 * Check whether this query should notify changes without data.
72 * @return true if this query should notify about changes with data
74 public boolean isSkipNotificationData() {
75 return skipNotificationData;
79 public String toString() {
80 final var helper = MoreObjects.toStringHelper(this);
81 if (startTime != null) {
82 helper.add("startTime", startTime.uriValue());
84 if (stopTime != null) {
85 helper.add("stopTime", stopTime.uriValue());
88 helper.add("filter", filter.uriValue());
90 return helper.add("skipNotificationData", skipNotificationData).toString();