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>>
- Type Parameters:
A- Argument typeD- Declared Statement representationE- Effective Statement representation
- All Implemented Interfaces:
StatementFactory<A,D, E>
- Direct Known Subclasses:
AbstractStatementSupport,ForwardingStatementSupport
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStatement context copy policy, indicating how should reactor handle statement copy operations.static interfaceStatementSupport.StatementEquality<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>> Abstract base class for comparators associated with statements with aStatementSupport.CopyPolicy.DECLARED_COPYcopy policy.static classStatementSupport.StatementPolicy<A,D extends org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<A>> A baseline class for implementing theStatementFactory.canReuseCurrent(Current, Current, Collection)contract in a manner which is consistent with a statement'sStatementSupport.CopyPolicy. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStatementSupport(org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition publicDefinition, StatementSupport.StatementPolicy<A, D> policy) protectedStatementSupport(StatementSupport<A, D, E> delegate) -
Method Summary
Modifier and TypeMethodDescriptionadaptArgumentValue(@NonNull StmtContext<A, D, E> ctx, @NonNull QNameModule targetModule) Adapts the argument value to match a new module.final @Nullable QNamefinal booleancanReuseCurrent(EffectiveStmtCtx.Current<A, D> copy, EffectiveStmtCtx.Current<A, D> current, Collection<? extends org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement<?, ?>> substatements) Determine reactor copy behaviour of a statement instance.final @NonNull StatementSupport.CopyPolicyReturn this statement'sStatementSupport.CopyPolicy.@NonNull org.opendaylight.yangtools.yang.model.api.meta.StatementDefinitionextractEffectiveState(E stmt) Return theEffectiveStatementStatefor a particular statement.final @NonNull Optional<org.opendaylight.yangtools.yang.model.api.meta.ArgumentDefinition>final @NonNull org.opendaylight.yangtools.yang.model.api.meta.StatementDefinitionReturns public statement definition, which will be present in built statements.@Nullable StatementSupport<?,?, ?> getSupportSpecificForArgument(String argument) If this support has argument specific supports, the method returns support specific for given argument (e.g.booleanReturns true if this support has argument specific supports.internArgument(String rawArgument) Given a raw string representation of an argument, try to use a shared representation.booleanReturns true if this statement support and all its substatements ignore config statements (e.g.booleanReturns true if this statement support and all its substatements ignore if-feature statements (e.g.voidInvoked when statement is closed duringModelProcessingPhase.FULL_DECLARATIONphase, only substatements from this phase are available.voidonLinkageDeclared(@NonNull StmtContext.Mutable<A, D, E> stmt) Invoked when statement is closed duringModelProcessingPhase.SOURCE_LINKAGEphase, only substatements from this and previous phase are available.voidonPreLinkageDeclared(@NonNull StmtContext.Mutable<A, D, E> stmt) Invoked when statement is closed duringModelProcessingPhase.SOURCE_PRE_LINKAGEphase, only substatements from this and previous phase are available.voidonStatementAdded(@NonNull StmtContext.Mutable<A, D, E> stmt) Invoked when a statement supported by this instance is added to build context.voidInvoked when statement is closed duringModelProcessingPhase.STATEMENT_DEFINITIONphase, only substatements from this phase are available.abstract AparseArgumentValue(StmtContext<?, ?, ?> ctx, String value) Parses textual representation of argument in object representation.final @NonNull QNameprotected abstract @Nullable SubstatementValidatorReturns corresponding substatement validator of a statement support.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory
copyEffective, createDeclared, createEffective
-
Constructor Details
-
StatementSupport
-
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
Return this statement'sStatementSupport.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:StatementFactoryDetermine 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
copyas to whether it would result in the same semantics ascurrentdoes, provided thatcurrent'ssubstatementsare properly propagated.- Specified by:
canReuseCurrentin interfaceStatementFactory<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 contextcurrent- Current effective contextsubstatements- Current effective substatements- Returns:
- True if the differences between
copyandcurrentdo not affect this statement's effective semantics.
-
extractEffectiveState
Description copied from interface:StatementFactoryReturn theEffectiveStatementStatefor 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:
extractEffectiveStatein interfaceStatementFactory<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
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
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
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 viaStmtContext.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
Invoked when statement is closed duringModelProcessingPhase.SOURCE_PRE_LINKAGEphase, 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
Invoked when statement is closed duringModelProcessingPhase.SOURCE_LINKAGEphase, 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
Invoked when statement is closed duringModelProcessingPhase.STATEMENT_DEFINITIONphase, 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
Invoked when statement is closed duringModelProcessingPhase.FULL_DECLARATIONphase, 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
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
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
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
-
argumentName
-
getArgumentDefinition
public final @NonNull Optional<org.opendaylight.yangtools.yang.model.api.meta.ArgumentDefinition> getArgumentDefinition()
-