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 com.google.common.base.MoreObjects;
12 import org.opendaylight.restconf.api.query.ChangedLeafNodesOnlyParam;
13 import org.opendaylight.restconf.api.query.ChildNodesOnlyParam;
14 import org.opendaylight.restconf.api.query.FilterParam;
15 import org.opendaylight.restconf.api.query.LeafNodesOnlyParam;
16 import org.opendaylight.restconf.api.query.SkipNotificationDataParam;
17 import org.opendaylight.restconf.api.query.StartTimeParam;
18 import org.opendaylight.restconf.api.query.StopTimeParam;
21 * Query parameters valid in the scope of a GET request on an event stream resource, as outline in
22 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-6.3">RFC8040 section 6.3</a>.
24 public record ReceiveEventsParams(
25 StartTimeParam startTime,
26 StopTimeParam stopTime,
28 LeafNodesOnlyParam leafNodesOnly,
29 SkipNotificationDataParam skipNotificationData,
30 ChangedLeafNodesOnlyParam changedLeafNodesOnly,
31 ChildNodesOnlyParam childNodesOnly) {
32 public ReceiveEventsParams {
33 if (stopTime != null && startTime == null) {
34 throw new IllegalArgumentException(StopTimeParam.uriName + " parameter has to be used with "
35 + StartTimeParam.uriName + " parameter");
37 if (changedLeafNodesOnly != null) {
38 if (leafNodesOnly != null) {
39 throw new IllegalArgumentException(ChangedLeafNodesOnlyParam.uriName + " parameter cannot be used with "
40 + LeafNodesOnlyParam.uriName + " parameter");
42 if (childNodesOnly != null) {
43 throw new IllegalArgumentException(ChangedLeafNodesOnlyParam.uriName + " parameter cannot be used with "
44 + ChildNodesOnlyParam.uriName + " parameter");
50 public String toString() {
51 final var helper = MoreObjects.toStringHelper(this);
52 if (startTime != null) {
53 helper.add("startTime", startTime.paramValue());
55 if (stopTime != null) {
56 helper.add("stopTime", stopTime.paramValue());
59 helper.add("filter", filter.paramValue());
61 if (leafNodesOnly != null) {
62 helper.add("leafNodesOnly", leafNodesOnly.value());
64 if (skipNotificationData != null) {
65 helper.add("skipNotificationData", skipNotificationData.value());
67 if (changedLeafNodesOnly != null) {
68 helper.add("changedLeafNodesOnly", changedLeafNodesOnly.value());
70 if (childNodesOnly != null) {
71 helper.add("childNodesOnly", childNodesOnly.value());
73 return helper.toString();