This interface is only used by Module, where it is a violation of
effective moidel separation from declared model.
Change-Id: I7de48f2c585f8daa7a29bc5b4e6a5ac33c994bbf
Signed-off-by: Robert Varga <rovarga@cisco.com>
*/
package org.opendaylight.yangtools.yang.model.api;
*/
package org.opendaylight.yangtools.yang.model.api;
-// TODO: merge into Module, makes no sense as standalone interface
+/**
+ * @deprecated This interface is a violation of the effective model contract. To look up the source of a particular
+ * module use a {@link org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository} or a similar
+ * lookup table.
+ */
+@Deprecated
public interface SourceStreamAware {
/**
* Get descriptive source path (usually file path) from which this module was parsed.
*/
String getModuleSourcePath();
public interface SourceStreamAware {
/**
* Get descriptive source path (usually file path) from which this module was parsed.
*/
String getModuleSourcePath();
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
*/
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 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 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.io.InputStream;
import java.util.Collection;
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.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+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.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<ModelProcessingPhase,StatementSupportBundle> supportedTerminology;
private final Map<ValidationBundleType,Collection<?>> supportedValidation;
public class CrossSourceStatementReactor {
private final Map<ModelProcessingPhase,StatementSupportBundle> supportedTerminology;
private final Map<ValidationBundleType,Collection<?>> supportedValidation;
- CrossSourceStatementReactor(Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology) {
+ CrossSourceStatementReactor(final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology) {
this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
this.supportedValidation = ImmutableMap.of();
}
this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
this.supportedValidation = ImmutableMap.of();
}
- CrossSourceStatementReactor(Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology, Map<ValidationBundleType,Collection<?>> supportedValidation) {
+ CrossSourceStatementReactor(final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology, final Map<ValidationBundleType,Collection<?>> supportedValidation) {
this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
this.supportedValidation = ImmutableMap.copyOf(supportedValidation);
}
this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
this.supportedValidation = ImmutableMap.copyOf(supportedValidation);
}
final Map<ModelProcessingPhase,StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
final Map<ValidationBundleType,Collection<?>> validationBundles = new EnumMap<>(ValidationBundleType.class);
final Map<ModelProcessingPhase,StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
final Map<ValidationBundleType,Collection<?>> 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;
}
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;
}
validationBundles.put(type,validationBundle);
return this;
}
public CrossSourceStatementReactor build() {
return new CrossSourceStatementReactor(bundles, validationBundles);
}
public CrossSourceStatementReactor build() {
return new CrossSourceStatementReactor(bundles, validationBundles);
}
}
public class BuildAction {
}
public class BuildAction {
private final BuildGlobalContext context;
public BuildAction() {
this.context = new BuildGlobalContext(supportedTerminology, supportedValidation);
}
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);
}
context.addSource(source);
}
- public void addSources(StatementStreamSource... sources) {
+ public void addSources(final StatementStreamSource... sources) {
for (StatementStreamSource source : sources) {
context.addSource(source);
}
for (StatementStreamSource source : sources) {
context.addSource(source);
}
return context.buildEffective();
}
return context.buildEffective();
}
- public SchemaContext buildEffective(Collection<ByteSource> yangByteSources) throws SourceException, ReactorException, IOException {
-
- for(ByteSource yangByteSource : yangByteSources) {
+ public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws SourceException,
+ ReactorException, IOException {
+ for (ByteSource yangByteSource : yangByteSources) {
addSource(new YangStatementSourceImpl(yangByteSource.openStream()));
}
return buildEffective();
}
addSource(new YangStatementSourceImpl(yangByteSource.openStream()));
}
return buildEffective();
}
- public SchemaContext buildEffective(List<InputStream> yangInputStreams) throws SourceException, ReactorException {
-
- for(InputStream yangInputStream : yangInputStreams) {
+ public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws SourceException,
+ ReactorException {
+ for (InputStream yangInputStream : yangInputStreams) {
addSource(new YangStatementSourceImpl(yangInputStream));
}
return buildEffective();
}
addSource(new YangStatementSourceImpl(yangInputStream));
}
return buildEffective();
}
- public Map<File, Module> buildEffectiveMappedToSource(
- List<File> yangFiles) throws SourceException, ReactorException,
- FileNotFoundException {
-
+ /**
+ * @deprecated This method was never used and relies on deprecated module methods.
+ */
+ @Deprecated
+ public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws SourceException,
+ ReactorException, FileNotFoundException {
if (yangFiles == null || yangFiles.isEmpty()) {
return Collections.emptyMap();
}
if (yangFiles == null || yangFiles.isEmpty()) {
return Collections.emptyMap();
}
Map<File, Module> sourceFileToModule = new HashMap<>();
for (File yangFile : yangFiles) {
Map<File, Module> 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<Module> modules = schema.getModules();
for (Module module : modules) {
pathToFile.put(yangFile.getPath(), yangFile);
}
EffectiveSchemaContext schema = buildEffective();
Set<Module> modules = schema.getModules();
for (Module module : modules) {
- sourceFileToModule.put(
- pathToFile.get(module.getModuleSourcePath()), module);
+ sourceFileToModule.put(pathToFile.get(module.getModuleSourcePath()), module);
}
return sourceFileToModule;
}
return sourceFileToModule;