X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fspi%2Fmeta%2FEffectiveStmtCtx.java;h=54e1c0231ebc1b25dab8fd6114b4603c63360df1;hb=refs%2Fchanges%2F58%2F94658%2F5;hp=e259f38ac31c50f74729301fa7098b97c8303482;hpb=d488240697fe799027361b994b2e086ea0f28429;p=yangtools.git diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java index e259f38ac3..54e1c0231e 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/EffectiveStmtCtx.java @@ -11,22 +11,21 @@ import static com.google.common.base.Verify.verifyNotNull; import com.google.common.annotations.Beta; import com.google.common.base.VerifyException; -import java.util.Map; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.yang.common.YangVersion; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; -import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; /** * Effective view of a {@link StmtContext} for the purposes of creating an {@link EffectiveStatement}. */ @Beta -public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable { +public interface EffectiveStmtCtx extends CommonStmtCtx, StmtContextCompat, Immutable { /** * Return parent of this context, if there is one. All statements except for top-level source statements, such as * {@code module} and {@code submodule}. @@ -51,9 +50,59 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable { */ @Beta interface Parent extends EffectiveStmtCtx { - // FIXME: 7.0.0: this should be Optional - boolean effectiveConfig(); + /** + * Effective {@code config} statement value. + */ + @Beta + enum EffectiveConfig { + /** + * We have an effective {@code config true} statement. + */ + TRUE(Boolean.TRUE), + /** + * We have an effective {@code config false} statement. + */ + FALSE(Boolean.FALSE), + /** + * We are in a context where {@code config} statements are ignored. + */ + IGNORED(null), + /** + * We are in a context where {@code config} is not determined, such as within a {@code grouping}. + */ + UNDETERMINED(null); + + private final Boolean config; + + EffectiveConfig(final @Nullable Boolean config) { + this.config = config; + } + + /** + * Return this value as a {@link Boolean} for use with {@link DataSchemaNode#effectiveConfig()}. + * + * @return A boolean or null + */ + public @Nullable Boolean asNullable() { + return config; + } + } + /** + * Return the effective {@code config} statement value. + * + * @return This statement's effective config + */ + @NonNull EffectiveConfig effectiveConfig(); + + /** + * Return the {@link SchemaPath} of this statement. Not all statements have a SchemaPath, in which case + * {@link Optional#empty()} is returned. + * + * @return Optional SchemaPath + * @deprecated Use of SchemaPath in the context of effective statements is going away. Consider not providing + * this information, if your users can exist without it. + */ // FIXME: 7.0.0: this needs to be a tri-state present/absent/disabled @Deprecated @NonNull Optional schemaPath(); @@ -62,6 +111,11 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable { default @NonNull SchemaPath getSchemaPath() { return schemaPath().orElseThrow(); } + + @Deprecated + default @Nullable SchemaPath wrapSchemaPath() { + return SchemaPathSupport.wrap(getSchemaPath()); + } } /** @@ -72,29 +126,12 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable { * @param Class representing declared version of this statement */ @Beta - interface Current> extends Parent { - - @NonNull CommonStmtCtx root(); - - @NonNull CopyHistory history(); - - @NonNull D declared(); + interface Current> extends Parent, NamespaceStmtCtx, BoundStmtCtxCompat { - > @Nullable V getFromNamespace(Class<@NonNull N> type, - T key); - - > Map getAllFromCurrentStmtCtxNamespace(Class type); - - @Nullable A argument(); - - default @NonNull A coerceArgument() { - return verifyNotNull(argument(), "Attempted to use non-existent argument"); - } + @NonNull QName moduleName(); @Nullable EffectiveStatement original(); - @NonNull YangVersion yangVersion(); - /** * Summon the Rabbit of Caerbannog. *