X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FCrossSourceStatementReactor.java;h=3856d7265840033bd0ab8920ba77f81dc06e6e17;hb=5ed67b08210c4c092cc6502748a2615d5e0a6970;hp=c206e0e6375c80b65f6f67062eff1ca23eed1f03;hpb=42abb28b99a02f9580f4676ce5c315628e5bcd24;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java index c206e0e637..3856d72658 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java @@ -7,43 +7,42 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.reactor; -import java.io.IOException; - +import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteSource; -import java.util.Set; -import java.io.FileNotFoundException; -import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream; -import java.util.HashMap; -import java.util.Collections; -import org.opendaylight.yangtools.yang.model.api.Module; import java.io.File; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; -import java.util.List; import java.util.Collection; -import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext; -import com.google.common.collect.ImmutableMap; +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 org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; +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 { private final Map supportedTerminology; private final Map> supportedValidation; - CrossSourceStatementReactor(Map supportedTerminology) { + CrossSourceStatementReactor(final Map supportedTerminology) { this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology); this.supportedValidation = ImmutableMap.of(); } - CrossSourceStatementReactor(Map supportedTerminology, Map> supportedValidation) { + CrossSourceStatementReactor(final Map supportedTerminology, final Map> supportedValidation) { this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology); this.supportedValidation = ImmutableMap.copyOf(supportedValidation); } @@ -61,15 +60,13 @@ public class CrossSourceStatementReactor { final Map bundles = new EnumMap<>(ModelProcessingPhase.class); final Map> validationBundles = new EnumMap<>(ValidationBundleType.class); - public Builder setBundle(ModelProcessingPhase phase,StatementSupportBundle bundle) { + public Builder setBundle(final ModelProcessingPhase phase,final StatementSupportBundle bundle) { bundles.put(phase, bundle); return this; } - public Builder setValidationBundle( - ValidationBundleType type, - Collection validationBundle) { + public Builder setValidationBundle(final ValidationBundleType type, final Collection validationBundle) { validationBundles.put(type,validationBundle); return this; } @@ -78,22 +75,20 @@ public class CrossSourceStatementReactor { public CrossSourceStatementReactor build() { return new CrossSourceStatementReactor(bundles, validationBundles); } - } public class BuildAction { - private final BuildGlobalContext context; public BuildAction() { this.context = new BuildGlobalContext(supportedTerminology, supportedValidation); } - public void addSource(StatementStreamSource source) { + public void addSource(final StatementStreamSource source) { context.addSource(source); } - public void addSources(StatementStreamSource... sources) { + public void addSources(final StatementStreamSource... sources) { for (StatementStreamSource source : sources) { context.addSource(source); } @@ -107,28 +102,30 @@ public class CrossSourceStatementReactor { return context.buildEffective(); } - public SchemaContext buildEffective(Collection yangByteSources) throws SourceException, ReactorException, IOException { - - for(ByteSource yangByteSource : yangByteSources) { + public SchemaContext buildEffective(final Collection yangByteSources) throws SourceException, + ReactorException, IOException { + for (ByteSource yangByteSource : yangByteSources) { addSource(new YangStatementSourceImpl(yangByteSource.openStream())); } return buildEffective(); } - public SchemaContext buildEffective(List yangInputStreams) throws SourceException, ReactorException { - - for(InputStream yangInputStream : yangInputStreams) { + public SchemaContext buildEffective(final List yangInputStreams) throws SourceException, + ReactorException { + for (InputStream yangInputStream : yangInputStreams) { addSource(new YangStatementSourceImpl(yangInputStream)); } return buildEffective(); } - public Map buildEffectiveMappedToSource( - List yangFiles) throws SourceException, ReactorException, - FileNotFoundException { - + /** + * @deprecated This method was never used and relies on deprecated module methods. + */ + @Deprecated + public Map buildEffectiveMappedToSource(final List yangFiles) throws SourceException, + ReactorException, FileNotFoundException { if (yangFiles == null || yangFiles.isEmpty()) { return Collections.emptyMap(); } @@ -137,16 +134,14 @@ public class CrossSourceStatementReactor { Map sourceFileToModule = new HashMap<>(); for (File yangFile : yangFiles) { - addSource(new YangStatementSourceImpl(new NamedFileInputStream( - yangFile, yangFile.getPath()))); + addSource(new YangStatementSourceImpl(new NamedFileInputStream(yangFile, yangFile.getPath()))); pathToFile.put(yangFile.getPath(), yangFile); } EffectiveSchemaContext schema = buildEffective(); Set modules = schema.getModules(); for (Module module : modules) { - sourceFileToModule.put( - pathToFile.get(module.getModuleSourcePath()), module); + sourceFileToModule.put(pathToFile.get(module.getModuleSourcePath()), module); } return sourceFileToModule;