Class StatementSupport<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>,E extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<A,D>>

java.lang.Object
org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport<A,D,E>
Type Parameters:
A - Argument type
D - Declared Statement representation
E - Effective Statement representation
All Implemented Interfaces:
StatementFactory<A,D,E>
Direct Known Subclasses:
AbstractStatementSupport, ForwardingStatementSupport

public abstract class StatementSupport<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>,E extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<A,D>> extends Object implements StatementFactory<A,D,E>
Support for processing concrete YANG statement.

This interface is intended to be implemented by developers, which want to introduce support of statement to parser. Consider subclassing AbstractStatementSupport for easier implementation of this interface.

  • Constructor Details

    • StatementSupport

      @Beta protected StatementSupport(StatementSupport<A,D,E> delegate)
    • StatementSupport

      @Beta protected StatementSupport(org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition publicDefinition, StatementSupport.StatementPolicy<A,D> policy)
  • Method Details

    • getPublicView

      public final @NonNull org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition getPublicView()
      Returns public statement definition, which will be present in built statements.

      Public statement definition may be used to provide different implementation of statement definition, which will not retain any build specific data or context.

      Returns:
      public statement definition, which will be present in built statements.
    • definition

      public @NonNull org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition definition()
    • copyPolicy

      public final @NonNull StatementSupport.CopyPolicy copyPolicy()
      Return this statement's StatementSupport.CopyPolicy. This is a static value, reflecting how this statement reacts to being replicated to a different context, without reflecting on behaviour of potential substatements, which would come into play in something like:
         
           module foo {
             namespace foo;
             prefix foo;
      
             extension note {
               argument string {
                 type string {
                   length 1..max;
                 }
               }
               description "Can be used in description/reference statements to attach additional notes";
             }
      
             description "A nice module extending description statement semantics" {
               foo:note "We can now attach description/reference a note.";
               foo:note "Also another note";
             }
           }
         
       

      In this scenario, it is the reactor's job to figure out what to do (like talking to substatements).

      Returns:
      This statement's copy policy
    • canReuseCurrent

      public final boolean canReuseCurrent(EffectiveStmtCtx.Current<A,D> copy, EffectiveStmtCtx.Current<A,D> current, Collection<? extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<?,?>> substatements)
      Description copied from interface: StatementFactory
      Determine reactor copy behaviour of a statement instance. Implementations classes are required to determine their operations with regard to their statements being replicated into different contexts -- potentially sharing instantiations.

      Implementations are examine copy as to whether it would result in the same semantics as current does, provided that current's substatements are properly propagated.

      Specified by:
      canReuseCurrent in interface StatementFactory<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>,E extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<A,D>>
      Parameters:
      copy - Copy of current effective context
      current - Current effective context
      substatements - Current effective substatements
      Returns:
      True if the differences between copy and current do not affect this statement's effective semantics.
    • extractEffectiveState

      public EffectiveStatementState extractEffectiveState(E stmt)
      Description copied from interface: StatementFactory
      Return the EffectiveStatementState for a particular statement. This acts as a summary for comparison with statements created by this factory, without taking substatements into account. This is an optional operation, it is always safe to return null.
      Specified by:
      extractEffectiveState in interface StatementFactory<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>,E extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<A,D>>
      Parameters:
      stmt - EffectiveStatement to examine
      Returns:
      EffectiveStatementState or null if the statement cannot be expressed
    • parseArgumentValue

      public abstract A parseArgumentValue(StmtContext<?,?,?> ctx, String value)
      Parses textual representation of argument in object representation.
      Parameters:
      ctx - Context, which may be used to access source-specific namespaces required for parsing.
      value - String representation of value, as was present in text source.
      Returns:
      Parsed value
      Throws:
      SourceException - when an inconsistency is detected.
    • adaptArgumentValue

      public A adaptArgumentValue(@NonNull StmtContext<A,D,E> ctx, @NonNull QNameModule targetModule)
      Adapts the argument value to match a new module. Default implementation returns original value stored in context, which is appropriate for most implementations.
      Parameters:
      ctx - Context, which may be used to access source-specific namespaces required for parsing.
      targetModule - Target module, may not be null.
      Returns:
      Adapted argument value.
    • onStatementAdded

      public void onStatementAdded(@NonNull StmtContext.Mutable<A,D,E> stmt)
      Invoked when a statement supported by this instance is added to build context. This allows implementations of this interface to start tracking the statement and perform any modifications to the build context hierarchy, accessible via StmtContext.getParentContext(). One such use is populating the parent's namespaces to allow it to locate this child statement.
      Parameters:
      stmt - Context of added statement. No substatements are available.
    • onPreLinkageDeclared

      public void onPreLinkageDeclared(@NonNull StmtContext.Mutable<A,D,E> stmt)
      Invoked when statement is closed during ModelProcessingPhase.SOURCE_PRE_LINKAGE phase, only substatements from this and previous phase are available.

      Implementation may use method to perform actions on this event or register modification action using StmtContext.Mutable.newInferenceAction(ModelProcessingPhase).

      Parameters:
      stmt - Context of added statement.
    • onLinkageDeclared

      public void onLinkageDeclared(@NonNull StmtContext.Mutable<A,D,E> stmt)
      Invoked when statement is closed during ModelProcessingPhase.SOURCE_LINKAGE phase, only substatements from this and previous phase are available.

      Implementation may use method to perform actions on this event or register modification action using StmtContext.Mutable.newInferenceAction(ModelProcessingPhase).

      Parameters:
      stmt - Context of added statement.
      Throws:
      SourceException - when an inconsistency is detected.
    • onStatementDefinitionDeclared

      public void onStatementDefinitionDeclared(StmtContext.Mutable<A,D,E> stmt)
      Invoked when statement is closed during ModelProcessingPhase.STATEMENT_DEFINITION phase, only substatements from this phase are available.

      Implementation may use method to perform actions on this event or register modification action using StmtContext.Mutable.newInferenceAction(ModelProcessingPhase).

      Parameters:
      stmt - Context of added statement. Argument and statement parent is accessible.
      Throws:
      SourceException - when an inconsistency is detected.
    • onFullDefinitionDeclared

      public void onFullDefinitionDeclared(StmtContext.Mutable<A,D,E> stmt)
      Invoked when statement is closed during ModelProcessingPhase.FULL_DECLARATION phase, only substatements from this phase are available.

      Implementation may use method to perform actions on this event or register modification action using StmtContext.Mutable.newInferenceAction(ModelProcessingPhase).

      Parameters:
      stmt - Context of added statement. Argument and statement parent is accessible.
      Throws:
      SourceException - when an inconsistency is detected.
    • substatementValidator

      protected abstract @Nullable SubstatementValidator substatementValidator()
      Returns corresponding substatement validator of a statement support.
      Returns:
      substatement validator or null, if substatement validator is not defined
    • hasArgumentSpecificSupports

      public boolean hasArgumentSpecificSupports()
      Returns true if this support has argument specific supports.
      Returns:
      true if this support has argument specific supports.
    • getSupportSpecificForArgument

      public @Nullable StatementSupport<?,?,?> getSupportSpecificForArgument(String argument)
      If this support has argument specific supports, the method returns support specific for given argument (e.g. type statement support need to be specialized based on its argument), otherwise returns null.
      Parameters:
      argument - argument of statement
      Returns:
      statement support specific for supplied argument or null
    • internArgument

      public String internArgument(String rawArgument)
      Given a raw string representation of an argument, try to use a shared representation. Default implementation does nothing.
      Parameters:
      rawArgument - Argument string
      Returns:
      A potentially-shard instance
    • isIgnoringIfFeatures

      @Beta public boolean isIgnoringIfFeatures()
      Returns true if this statement support and all its substatements ignore if-feature statements (e.g. yang-data extension defined in RFC 8040). Default implementation returns false.
      Returns:
      true if this statement support ignores if-feature statements, otherwise false.
    • isIgnoringConfig

      @Beta public boolean isIgnoringConfig()
      Returns true if this statement support and all its substatements ignore config statements (e.g. yang-data extension defined in RFC 8040). Default implementation returns false.
      Returns:
      true if this statement support ignores config statements, otherwise false.
    • statementName

      public final @NonNull QName statementName()
    • argumentName

      public final @Nullable QName argumentName()
    • getArgumentDefinition

      public final @NonNull Optional<org.opendaylight.yangtools.yang.model.api.meta.ArgumentDefinition> getArgumentDefinition()