Add the ability to retain DeclarationReference
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / meta / DeclaredStatement.java
index 94521207bcf6cec73fb2dab7b437955f52b90708..11e5bb12651fa78dfa90c068fb8a4b7a9a3053be 100644 (file)
@@ -53,6 +53,23 @@ public interface DeclaredStatement<A> extends ModelStatement<A> {
         return Collections2.transform(Collections2.filter(declaredSubstatements(), type::isInstance), type::cast);
     }
 
+    /**
+     * Returns a {@link DeclarationReference} associated with this statement, if available.
+     *
+     * @apiNote
+     *     This method does not contribute any semantic information and is provided purely as a conduit for
+     *     implementation-specific information where a statement instance came from.
+     *
+     * @implSpec
+     *     The default implementation returns {@link Optional#empty()}.
+     *
+     * @return A {@link DeclarationReference} associated with this statement or {@link Optional#empty()}.
+     */
+    @Beta
+    default @NonNull Optional<DeclarationReference> declarationReference() {
+        return Optional.empty();
+    }
+
     /**
      * Find the first effective substatement of specified type.
      *