Add EventInstantAware interface 24/81324/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Mar 2019 12:55:15 +0000 (13:55 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 29 Mar 2019 13:18:38 +0000 (14:18 +0100)
This interface will be used to carry the equivalent of RFC5277
notification eventTime. It is modeled exactly the same way as
DOMEvent/DOMNotification, hence it will allow us to bridge the gap
in binding-dom-adapter, where we are losing this information.

JIRA: MDSAL-282
Change-Id: Ie93015c2609a2d1c59df6c63f76511aa68867832
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 992122145777924ad5b3a52da65188d8a91b8246)

binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/EventInstantAware.java [new file with mode: 0644]
binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/Notification.java

diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/EventInstantAware.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/EventInstantAware.java
new file mode 100644 (file)
index 0000000..a972519
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.binding;
+
+import com.google.common.annotations.Beta;
+import java.time.Instant;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * This interface is mixed in into implementations of other constructs, such as {@link Notification} to add the time
+ * when the event occurred.
+ */
+@Beta
+public interface EventInstantAware {
+    /**
+     * Get the time of the event occurrence.
+     *
+     * @return the event time
+     */
+    @NonNull Instant eventInstant();
+}
index f073fa705eca794083a7f2991971c4c3f75d03a1..7345ed66eda2ed7001fe555745bc664dbbcb3d2f 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.yangtools.yang.binding;
 
 /**
- * Marker interface for YANG-defined notifications.
+ * Marker interface for YANG-defined notifications. This interface should never be implemented directly. A concrete
+ * Notification and its implementations may choose to also extend/implement the {@link EventInstantAware} interface.
+ * In case they do, {@link EventInstantAware#eventInstant()} returns the time when this notification was generated.
  */
 public interface Notification extends DataContainer {