2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.yangtools.yang.test.util;
11 import com.google.common.annotations.Beta;
13 import java.io.FileFilter;
14 import java.io.FileNotFoundException;
15 import java.io.InputStream;
17 import java.net.URISyntaxException;
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.Collection;
21 import java.util.List;
22 import java.util.function.Predicate;
23 import org.opendaylight.yangtools.yang.common.QName;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
26 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
27 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
28 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
29 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
30 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
31 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
32 import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
35 * Utility class which provides convenience methods for producing effective schema context based on the supplied
36 * yang/yin sources or paths to these sources
39 public final class YangParserTestUtils {
41 private static final FileFilter YANG_FILE_FILTER = file -> {
42 final String name = file.getName().toLowerCase();
43 return name.endsWith(".yang") && file.isFile();
46 private YangParserTestUtils() {
47 throw new UnsupportedOperationException("Utility class should not be instantiated.");
51 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
52 * default mode and all YANG features are supported.
54 * @param sources YANG sources to be parsed
56 * @return effective schema context
58 * @throws ReactorException if there is an error in one of the parsed YANG sources
60 public static SchemaContext parseYangSources(final YangStatementSourceImpl... sources) throws ReactorException {
61 return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
65 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
68 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
69 * @param sources YANG sources to be parsed
71 * @return effective schema context
72 * @throws ReactorException if there is an error in one of the parsed YANG sources
74 public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
75 final YangStatementSourceImpl... sources) throws ReactorException {
76 return parseYangSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, sources);
80 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
82 * @param statementParserMode mode of statement parser
83 * @param sources YANG sources to be parsed
85 * @return effective schema context
86 * @throws ReactorException if there is an error in one of the parsed YANG sources
88 public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
89 final YangStatementSourceImpl... sources) throws ReactorException {
90 return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
94 * Creates a new effective schema context containing the specified YANG sources.
96 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
97 * @param statementParserMode mode of statement parser
98 * @param sources YANG sources to be parsed
100 * @return effective schema context
102 * @throws ReactorException if there is an error in one of the parsed YANG sources
104 public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
105 final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources) throws ReactorException {
106 final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
107 statementParserMode, isFeatureSupported);
108 reactor.addSources(sources);
110 return reactor.buildEffective();
114 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
115 * default mode and all YANG features are supported.
117 * @param files YANG files to be parsed
119 * @return effective schema context
121 * @throws ReactorException if there is an error in one of the parsed YANG sources
122 * @throws FileNotFoundException if one of the specified files does not exist
124 public static SchemaContext parseYangSources(final File... files) throws ReactorException, FileNotFoundException {
125 return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, files);
129 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
132 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
133 * @param files YANG files to be parsed
135 * @return effective schema context
137 * @throws ReactorException if there is an error in one of the parsed YANG sources
138 * @throws FileNotFoundException if one of the specified files does not exist
140 public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported, final File... files)
141 throws ReactorException, FileNotFoundException {
142 return parseYangSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, files);
146 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
148 * @param statementParserMode mode of statement parser
149 * @param files YANG files to be parsed
151 * @return effective schema context
153 * @throws ReactorException if there is an error in one of the parsed YANG sources
154 * @throws FileNotFoundException if one of the specified files does not exist
156 public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final File... files)
157 throws ReactorException, FileNotFoundException {
158 return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, files);
162 * Creates a new effective schema context containing the specified YANG sources.
164 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
165 * @param statementParserMode mode of statement parser
166 * @param files YANG files to be parsed
168 * @return effective schema context
170 * @throws ReactorException if there is an error in one of the parsed YANG sources
171 * @throws FileNotFoundException if one of the specified files does not exist
173 public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
174 final StatementParserMode statementParserMode, final File... files) throws ReactorException,
175 FileNotFoundException {
176 final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[files.length];
177 for (int i = 0; i < files.length; i++) {
178 sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
181 return parseYangSources(isFeatureSupported, statementParserMode, sources);
185 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
186 * default mode and all YANG features are supported.
188 * @param files collection of YANG files to be parsed
190 * @return effective schema context
192 * @throws ReactorException if there is an error in one of the parsed YANG sources
193 * @throws FileNotFoundException if one of the specified files does not exist
195 public static SchemaContext parseYangSources(final Collection<File> files) throws ReactorException,
196 FileNotFoundException {
197 return parseYangSources(files, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
201 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
204 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
205 * @param files collection of YANG files to be parsed
207 * @return effective schema context
209 * @throws ReactorException if there is an error in one of the parsed YANG sources
210 * @throws FileNotFoundException if one of the specified files does not exist
212 public static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported)
213 throws ReactorException, FileNotFoundException {
214 return parseYangSources(files, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
218 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
220 * @param statementParserMode mode of statement parser
221 * @param files collection of YANG files to be parsed
223 * @return effective schema context
225 * @throws ReactorException if there is an error in one of the parsed YANG sources
226 * @throws FileNotFoundException if one of the specified files does not exist
228 public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
229 throws ReactorException, FileNotFoundException {
230 return parseYangSources(files, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
234 * Creates a new effective schema context containing the specified YANG sources.
236 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
237 * @param statementParserMode mode of statement parser
238 * @param files collection of YANG files to be parsed
240 * @return effective schema context
242 * @throws ReactorException if there is an error in one of the parsed YANG sources
243 * @throws FileNotFoundException if one of the specified files does not exist
245 public static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported,
246 final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
247 return parseYangSources(isFeatureSupported, statementParserMode, files.toArray(new File[files.size()]));
251 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
252 * default mode and all YANG features are supported.
254 * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
256 * @return effective schema context
258 * @throws ReactorException if there is an error in one of the parsed YANG sources
259 * @throws FileNotFoundException if the specified directory does not exist
260 * @throws URISyntaxException if the specified directory does not exist
262 public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws ReactorException,
263 FileNotFoundException, URISyntaxException {
264 return parseYangSources(yangSourcesDirectoryPath, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
268 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
271 * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
272 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
274 * @return effective schema context
276 * @throws ReactorException if there is an error in one of the parsed YANG sources
277 * @throws FileNotFoundException if the specified directory does not exist
278 * @throws URISyntaxException if the specified directory does not exist
280 public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
281 final Predicate<QName> isFeatureSupported) throws ReactorException, FileNotFoundException, URISyntaxException {
282 return parseYangSources(yangSourcesDirectoryPath, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
286 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
288 * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
289 * @param statementParserMode mode of statement parser
291 * @return effective schema context
293 * @throws ReactorException if there is an error in one of the parsed YANG sources
294 * @throws FileNotFoundException if the specified directory does not exist
295 * @throws URISyntaxException if the specified directory does not exist
297 public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
298 final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException, URISyntaxException {
299 return parseYangSources(yangSourcesDirectoryPath, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
303 * Creates a new effective schema context containing the specified YANG sources.
305 * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
306 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
307 * @param statementParserMode mode of statement parser
309 * @return effective schema context
311 * @throws ReactorException if there is an error in one of the parsed YANG sources
312 * @throws FileNotFoundException if the specified directory does not exist
313 * @throws URISyntaxException if the specified directory does not exist
315 public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
316 final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode) throws ReactorException,
317 FileNotFoundException, URISyntaxException {
318 final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
319 final File dir = new File(directoryPath);
321 return parseYangSources(isFeatureSupported, statementParserMode, dir.listFiles(YANG_FILE_FILTER));
325 * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
326 * default mode and all YANG features are supported.
328 * @param yangSourcePath relative path to the YANG file to be parsed
330 * @return effective schema context
332 * @throws ReactorException if there is an error in the parsed YANG source
333 * @throws FileNotFoundException if the specified file does not exist
334 * @throws URISyntaxException if the specified file does not exist
336 public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException,
337 FileNotFoundException, URISyntaxException {
338 return parseYangSource(yangSourcePath, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
342 * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
345 * @param yangSourcePath relative path to the YANG file to be parsed
346 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG model are resolved
348 * @return effective schema context
350 * @throws ReactorException if there is an error in the parsed YANG source
351 * @throws FileNotFoundException if the specified file does not exist
352 * @throws URISyntaxException if the specified file does not exist
354 public static SchemaContext parseYangSource(final String yangSourcePath, final Predicate<QName> isFeatureSupported)
355 throws ReactorException, FileNotFoundException, URISyntaxException {
356 return parseYangSource(yangSourcePath, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
360 * Creates a new effective schema context containing the specified YANG source. All YANG features are supported.
362 * @param yangSourcePath relative path to the YANG file to be parsed
363 * @param statementParserMode mode of statement parser
365 * @return effective schema context
367 * @throws ReactorException if there is an error in the parsed YANG source
368 * @throws FileNotFoundException if the specified file does not exist
369 * @throws URISyntaxException if the specified file does not exist
371 public static SchemaContext parseYangSource(final String yangSourcePath, final StatementParserMode statementParserMode)
372 throws ReactorException, FileNotFoundException, URISyntaxException {
373 return parseYangSource(yangSourcePath, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
377 * Creates a new effective schema context containing the specified YANG source.
379 * @param yangSourcePath relative path to the YANG file to be parsed
380 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG model are resolved
381 * @param statementParserMode mode of statement parser
383 * @return effective schema context
385 * @throws ReactorException if there is an error in the parsed YANG source
386 * @throws FileNotFoundException if the specified file does not exist
387 * @throws URISyntaxException if the specified file does not exist
389 public static SchemaContext parseYangSource(final String yangSourcePath, final Predicate<QName> isFeatureSupported,
390 final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException, URISyntaxException {
391 final URI sourcePath = YangParserTestUtils.class.getResource(yangSourcePath).toURI();
392 final File sourceFile = new File(sourcePath);
393 return parseYangSources(isFeatureSupported, statementParserMode, sourceFile);
397 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
398 * default mode and all YANG features are supported.
400 * @param yangDirs relative paths to the directories containing YANG files to be parsed
401 * @param yangFiles relative paths to the YANG files to be parsed
403 * @return effective schema context
405 * @throws ReactorException if there is an error in one of the parsed YANG sources
406 * @throws FileNotFoundException if one of the specified directories or files does not exist
407 * @throws URISyntaxException if one of the specified directories or files does not exist
409 public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles)
410 throws FileNotFoundException, ReactorException, URISyntaxException {
411 return parseYangSources(yangDirs, yangFiles, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
415 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
418 * @param yangDirs relative paths to the directories containing YANG files to be parsed
419 * @param yangFiles relative paths to the YANG files to be parsed
420 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
422 * @return effective schema context
424 * @throws ReactorException if there is an error in one of the parsed YANG sources
425 * @throws FileNotFoundException if one of the specified directories or files does not exist
426 * @throws URISyntaxException if one of the specified directories or files does not exist
428 public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
429 final Predicate<QName> isFeatureSupported) throws FileNotFoundException, ReactorException, URISyntaxException {
430 return parseYangSources(yangDirs, yangFiles, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
434 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
436 * @param yangDirs relative paths to the directories containing YANG files to be parsed
437 * @param yangFiles relative paths to the YANG files to be parsed
438 * @param statementParserMode mode of statement parser
440 * @return effective schema context
442 * @throws ReactorException if there is an error in one of the parsed YANG sources
443 * @throws FileNotFoundException if one of the specified directories or files does not exist
444 * @throws URISyntaxException if one of the specified directories or files does not exist
446 public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
447 final StatementParserMode statementParserMode) throws FileNotFoundException, ReactorException,
449 return parseYangSources(yangDirs, yangFiles, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
453 * Creates a new effective schema context containing the specified YANG sources.
455 * @param yangDirs relative paths to the directories containing YANG files to be parsed
456 * @param yangFiles relative paths to the YANG files to be parsed
457 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
458 * @param statementParserMode mode of statement parser
460 * @return effective schema context
462 * @throws ReactorException if there is an error in one of the parsed YANG sources
463 * @throws FileNotFoundException if one of the specified directories or files does not exist
464 * @throws URISyntaxException if one of the specified directories or files does not exist
466 public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
467 final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode)
468 throws FileNotFoundException, ReactorException, URISyntaxException {
469 final List<File> allYangFiles = new ArrayList<>();
470 for (final String yangDir : yangDirs) {
471 allYangFiles.addAll(getYangFiles(yangDir));
474 for (final String yangFile : yangFiles) {
475 final URI filePath = YangParserTestUtils.class.getResource(yangFile).toURI();
476 allYangFiles.add(new File(filePath));
479 return parseYangSources(allYangFiles, isFeatureSupported, statementParserMode);
482 private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) throws URISyntaxException {
483 final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
484 final File dir = new File(directoryPath);
486 return Arrays.asList(dir.listFiles(YANG_FILE_FILTER));
490 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
491 * default mode and all YANG features are supported.
493 * @param filePaths relative paths to the YANG files to be parsed
495 * @return effective schema context
497 * @throws ReactorException if there is an error in one of the parsed YANG sources
499 public static SchemaContext parseYangSources(final List<String> filePaths) throws ReactorException {
500 return parseYangSources(filePaths, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
504 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
507 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
508 * @param filePaths relative paths to the YANG files to be parsed
510 * @return effective schema context
512 * @throws ReactorException if there is an error in one of the parsed YANG sources
514 public static SchemaContext parseYangSources(final List<String> filePaths, final Predicate<QName> isFeatureSupported)
515 throws ReactorException {
516 return parseYangSources(filePaths, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
520 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
522 * @param statementParserMode mode of statement parser
523 * @param filePaths relative paths to the YANG files to be parsed
525 * @return effective schema context
527 * @throws ReactorException if there is an error in one of the parsed YANG sources
529 public static SchemaContext parseYangSources(final List<String> filePaths,final StatementParserMode statementParserMode)
530 throws ReactorException {
531 return parseYangSources(filePaths, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
535 * Creates a new effective schema context containing the specified YANG sources.
537 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
538 * @param statementParserMode mode of statement parser
539 * @param filePaths relative paths to the YANG files to be parsed
541 * @return effective schema context
543 * @throws ReactorException if there is an error in one of the parsed YANG sources
545 public static SchemaContext parseYangSources(final List<String> filePaths, final Predicate<QName> isFeatureSupported,
546 final StatementParserMode statementParserMode) throws ReactorException {
547 final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[filePaths.size()];
549 for (int i = 0; i < filePaths.size(); i++) {
550 sources[i] = new YangStatementSourceImpl(YangParserTestUtils.class.getResourceAsStream(filePaths.get(i)));
553 return parseYangSources(isFeatureSupported, statementParserMode, sources);
557 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
558 * default mode and all YANG features are supported.
560 * @param streams input streams containing YANG sources to be parsed
562 * @return effective schema context
564 * @throws ReactorException if there is an error in one of the parsed YANG sources
566 public static SchemaContext parseYangStreams(final List<InputStream> streams) throws ReactorException {
567 return parseYangStreams(streams, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
571 * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
574 * @param streams input streams containing YANG sources to be parsed
575 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
577 * @return effective schema context
579 * @throws ReactorException if there is an error in one of the parsed YANG sources
581 public static SchemaContext parseYangStreams(final List<InputStream> streams, final Predicate<QName> isFeatureSupported)
582 throws ReactorException {
583 return parseYangStreams(streams, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
587 * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
589 * @param streams input streams containing YANG sources to be parsed
590 * @param statementParserMode mode of statement parser
592 * @return effective schema context
594 * @throws ReactorException if there is an error in one of the parsed YANG sources
596 public static SchemaContext parseYangStreams(final List<InputStream> streams, final StatementParserMode statementParserMode)
597 throws ReactorException {
598 return parseYangStreams(streams, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
602 * Creates a new effective schema context containing the specified YANG sources.
604 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
605 * @param statementParserMode mode of statement parser
606 * @param streams input streams containing YANG sources to be parsed
608 * @return effective schema context
610 * @throws ReactorException if there is an error in one of the parsed YANG sources
612 public static SchemaContext parseYangStreams(final List<InputStream> streams, final Predicate<QName> isFeatureSupported,
613 final StatementParserMode statementParserMode) throws ReactorException {
614 final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
615 statementParserMode, isFeatureSupported);
616 return reactor.buildEffective(streams);
620 * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
621 * default mode and all YANG features are supported.
623 * @param sources YIN sources to be parsed
625 * @return effective schema context
627 * @throws ReactorException if there is an error in one of the parsed YIN sources
629 public static SchemaContext parseYinSources(final YinStatementStreamSource... sources) throws ReactorException {
630 return parseYinSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
634 * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
637 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
638 * @param sources YIN sources to be parsed
640 * @return effective schema context
641 * @throws ReactorException if there is an error in one of the parsed YIN sources
643 public static SchemaContext parseYinSources(final Predicate<QName> isFeatureSupported,
644 final YinStatementStreamSource... sources) throws ReactorException {
645 return parseYinSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, sources);
649 * Creates a new effective schema context containing the specified YIN sources. All YANG features are supported.
651 * @param statementParserMode mode of statement parser
652 * @param sources YIN sources to be parsed
654 * @return effective schema context
656 * @throws ReactorException if there is an error in one of the parsed YIN sources
658 public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
659 final YinStatementStreamSource... sources) throws ReactorException {
660 return parseYinSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
664 * Creates a new effective schema context containing the specified YIN sources.
666 * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
667 * @param statementParserMode mode of statement parser
668 * @param sources YIN sources to be parsed
670 * @return effective schema context
672 * @throws ReactorException if there is an error in one of the parsed YIN sources
674 public static SchemaContext parseYinSources(final Predicate<QName> isFeatureSupported,
675 final StatementParserMode statementParserMode, final YinStatementStreamSource... sources) throws ReactorException {
676 final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
677 statementParserMode, isFeatureSupported);
678 reactor.addSources(sources);
680 return reactor.buildEffective();