Add the ability to retain DeclarationReference
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / source / StatementSourceReference.java
index f686149439a4e4c1a843f8da877c26eca406f995..18ff710225ec46a0071f467b38c989c52465ff89 100644 (file)
@@ -7,7 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
 
 /**
  * Reference of statement source. Statement source reference serves to provide information, why a statement was defined
@@ -15,28 +19,33 @@ import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
  *
  * <p>
  * Reasons for introduction of statement could be various, but most obvious one is explicit declaration in model source
- * text such as {@link DeclarationInTextSource}.
+ * text such as {@link ExplicitStatement}.
  */
-public interface StatementSourceReference {
+public abstract class StatementSourceReference implements Immutable {
     /**
-     * Returns source type.
+     * Returns the {@link StatementOrigin} associated with this reference.
      *
-     * @return {@link StatementSource#DECLARATION} if statement was explicitly
-     *         declared in YANG model source, {@link StatementSource#CONTEXT} if statement
-     *         was inferred.
+     * @return {@link StatementOrigin#DECLARATION} if statement was explicitly declared in YANG model source,
+     *         {@link StatementOrigin#CONTEXT} if statement was inferred.
      */
-    StatementSource getStatementSource();
+    public abstract @NonNull StatementOrigin statementOrigin();
+
+    /**
+     * Returns the {@link DeclarationReference} associated with this reference, if available.
+     *
+     * @return A {@link DeclarationReference} or null.
+     */
+    public abstract @Nullable DeclarationReference declarationReference();
 
     /**
      * Returns human readable representation of statement source.
      *
      * <p>
-     * Implementations of this interface should override {@link #toString()},
-     * since it may be used in error reporting to provide context
-     * information for model designer to debug errors in its mode.
+     * Implementations of this interface should override {@link #toString()}, since it may be used in error reporting
+     * to provide context information for model designer to debug errors in its mode.
      *
      * @return human readable representation of statement source.
      */
     @Override
-    String toString();
+    public abstract @NonNull String toString();
 }