import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteSource;
-import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
-import java.util.Collections;
import java.util.EnumMap;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.function.Predicate;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
public class CrossSourceStatementReactor {
return buildEffective();
}
-
- /**
- * @deprecated This method was never used and relies on deprecated
- * module methods.
- */
- @Deprecated
- public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws ReactorException,
- FileNotFoundException {
- if (yangFiles == null || yangFiles.isEmpty()) {
- return Collections.emptyMap();
- }
-
- final Map<String, File> pathToFile = new HashMap<>();
- final Map<File, Module> sourceFileToModule = new HashMap<>();
-
- for (final File yangFile : yangFiles) {
- addSource(new YangStatementSourceImpl(new NamedFileInputStream(yangFile, yangFile.getPath())));
- pathToFile.put(yangFile.getPath(), yangFile);
- }
-
- final EffectiveSchemaContext schema = buildEffective();
- final Set<Module> modules = schema.getModules();
- for (final Module module : modules) {
- sourceFileToModule.put(pathToFile.get(module.getModuleSourcePath()), module);
- }
-
- return sourceFileToModule;
- }
}
}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.yangtools.yang.stmt;
-
-import static org.junit.Assert.assertEquals;
-import java.io.FileNotFoundException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.Map;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import java.util.List;
-import java.util.Arrays;
-import java.net.URISyntaxException;
-import java.io.File;
-import org.junit.Test;
-
-public class MappedEffectiveBuildTest {
-
- @Test
- public void mappedBuildTest() throws URISyntaxException, SourceException,
- FileNotFoundException, ReactorException {
- File sourceDir = new File(getClass().getResource("/mapped-build/")
- .toURI());
- List<File> yangFiles = Arrays.asList(sourceDir.listFiles());
-
- assertEquals(4, yangFiles.size());
-
- BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- Map<File, Module> parseYangModelsMapped = reactor
- .buildEffectiveMappedToSource(yangFiles);
-
- assertEquals(2, parseYangModelsMapped.size());
-
- Set<Entry<File, Module>> mapEntrySet = parseYangModelsMapped.entrySet();
- for (Entry<File, Module> entry : mapEntrySet) {
- assertEquals(entry.getKey().getPath(), entry.getValue()
- .getModuleSourcePath());
- }
- }
-}