From: Igor Foltin Date: Thu, 13 Apr 2017 07:59:35 +0000 (+0200) Subject: Update the developer docs X-Git-Tag: release/nitrogen~124 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F54942%2F1;p=yangtools.git Update the developer docs Update the docs related to the usage of if-feature resolution mode of the YANG statement parser. Change-Id: Id2201d7082b2b744f98c09801530bc8ad2205d65 Signed-off-by: Igor Foltin --- diff --git a/docs/src/main/asciidoc/developer/introduction.adoc b/docs/src/main/asciidoc/developer/introduction.adoc index a6cb324464..904204eee1 100644 --- a/docs/src/main/asciidoc/developer/introduction.adoc +++ b/docs/src/main/asciidoc/developer/introduction.adoc @@ -173,27 +173,24 @@ The YANG statement parser can work in three modes: The default mode is active when you initialize the parsing cycle as usual by calling the method newBuild() without passing any arguments to it. The second and third mode can be activated by invoking the newBuild() with a special argument. You can either activate just one of them or both by passing proper arguments. Let us explain how these modes work. -Mode with active resolution of if-features makes yang statements containing an if-feature statement conditional based on the supported features. These features are provided in the form of a QName-based java.util.function.Predicate object. In the example below, only two features are supported: example-feature-1 and example-feature-2. The Predicate which contains this information is passed to the method newBuild() and the mode is activated. +Mode with active resolution of if-features makes yang statements containing an if-feature statement conditional based on the supported features. These features are provided in the form of a QName-based java.util.Set object. In the example below, only two features are supported: example-feature-1 and example-feature-2. The Set is passed to the method newBuild() and the mode is activated. [source, java] ---- -Predicate isFeatureSupported = qName -> { - Set supportedFeatures = new HashSet<>(); - supportedFeatures.add(QName.create("example-namespace", "2016-08-31", "example-feature-1")); - supportedFeatures.add(QName.create("example-namespace", "2016-08-31", "example-feature-2")); - return supportedFeatures.contains(qName); -} +Set supportedFeatures = ImmutableSet.of( + QName.create("example-namespace", "2016-08-31", "example-feature-1"), + QName.create("example-namespace", "2016-08-31", "example-feature-2")); -CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(isFeatureSupported); +CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures); ---- -In case when no features should be supported, you should provide a Predicate object whose test() method just returns false. +In case when no features should be supported, you should provide an empty Set object. [source, java] ---- -Predicate isFeatureSupported = qName -> false; +Set supportedFeatures = ImmutableSet.of(); -CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(isFeatureSupported); +CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(supportedFeatures); ---- When this mode is not activated, all features in the processed YANG sources are supported.