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 SkipNotificationDataParam skipNotificationData;
23 private final LeafNodesOnlyParam leafNodesOnly;
24 private final StartTimeParam startTime;
25 private final StopTimeParam stopTime;
26 private final FilterParam filter;
28 private NotificationQueryParams(final StartTimeParam startTime, final StopTimeParam stopTime,
29 final FilterParam filter, final LeafNodesOnlyParam leafNodesOnly,
30 final SkipNotificationDataParam skipNotificationData) {
31 this.startTime = startTime;
32 this.stopTime = stopTime;
34 this.leafNodesOnly = leafNodesOnly;
35 this.skipNotificationData = skipNotificationData;
38 public static @NonNull NotificationQueryParams of(final StartTimeParam startTime, final StopTimeParam stopTime,
39 final FilterParam filter, final LeafNodesOnlyParam leafNodesOnly,
40 final SkipNotificationDataParam skipNotificationData) {
41 checkArgument(stopTime == null || startTime != null,
42 "Stop-time parameter has to be used with start-time parameter.");
43 return new NotificationQueryParams(startTime, stopTime, filter, leafNodesOnly, skipNotificationData);
47 * Get start-time query parameter.
51 public @Nullable StartTimeParam startTime() {
56 * Get stop-time query parameter.
60 public @Nullable StopTimeParam stopTime() {
65 * Get filter query parameter.
69 public @Nullable FilterParam filter() {
74 * Get odl-leaf-nodes-only query parameter.
76 * @return odl-leaf-nodes-only
78 public @Nullable LeafNodesOnlyParam leafNodesOnly() {
83 * Get odl-skip-notification-data query parameter.
85 * @return odl-skip-notification-data
87 public @Nullable SkipNotificationDataParam skipNotificationData() {
88 return skipNotificationData;
92 public String toString() {
93 final var helper = MoreObjects.toStringHelper(this);
94 if (startTime != null) {
95 helper.add("startTime", startTime.paramValue());
97 if (stopTime != null) {
98 helper.add("stopTime", stopTime.paramValue());
100 if (filter != null) {
101 helper.add("filter", filter.paramValue());
103 if (leafNodesOnly != null) {
104 helper.add("leafNodesOnly", leafNodesOnly.value());
106 if (skipNotificationData != null) {
107 helper.add("skipNotificationData", skipNotificationData.value());
109 return helper.toString();