/** * Add main sources. All main sources are present in resulting SchemaContext. * * @param sources * which should be added into main sources * @return This build action, for fluent use. */ public @NonNull BuildAction addSources(final StatementStreamSource... sources) { addSources(Arrays.asList(sources)); return this; }
/** * Returns the schema context of the YANG files present in a directory. * * @param di directory path * @return YANG schema context * @throws SvcLogicException when YANG file reading fails */ static SchemaContext getSchemaCtxFromDir(String di) throws SvcLogicException { Path d = Paths.get(di); File dir = d.toFile(); List<File> yangFiles = new LinkedList<>(); getYangFiles(dir, yangFiles); final Collection<YangStatementStreamSource> sources = new ArrayList<>(yangFiles.size()); for (File file : yangFiles) { try { sources.add(create(forFile(file))); } catch (IOException | YangSyntaxErrorException e) { throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e); } } final CrossSourceStatementReactor.BuildAction reactor = defaultReactor() .newBuild(DEFAULT_MODE).addSources(sources); try { return reactor.buildEffective(); } catch (ReactorException e) { throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e); } }
@Override public YangParser addSource(final SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException { buildAction.addSources(sourceToStatementStream(source)); return null; }
@Override public YangParser addSource(final SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException { buildAction.addSources(sourceToStatementStream(source)); return null; }