import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.SetMultimap;
import com.google.common.collect.Table;
import com.google.common.collect.TreeBasedTable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.util.RecursiveObjectLeaker;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
private final Map<QName, StatementDefinitionContext<?, ?, ?>> modelDefinedStmtDefs = new HashMap<>();
private final Map<Class<?>, NamespaceBehaviourWithListeners<?, ?, ?>> supportedNamespaces = new HashMap<>();
private final List<MutableStatement> mutableStatementsToSeal = new ArrayList<>();
- private final Map<ModelProcessingPhase, StatementSupportBundle> supports;
+ private final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports;
private final Set<SourceSpecificContext> sources = new HashSet<>();
- private final Set<YangVersion> supportedVersions;
+ private final ImmutableSet<YangVersion> supportedVersions;
private final boolean enabledSemanticVersions;
private Set<SourceSpecificContext> libSources = new HashSet<>();
private ModelProcessingPhase currentPhase = ModelProcessingPhase.INIT;
private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
- BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
- final Map<ValidationBundleType, Collection<?>> supportedValidation,
+ BuildGlobalContext(final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports,
+ final ImmutableMap<ValidationBundleType, Collection<?>> supportedValidation,
final StatementParserMode statementParserMode) {
this.supports = requireNonNull(supports, "BuildGlobalContext#supports cannot be null");
throw new IllegalArgumentException("Unhandled parser mode " + statementParserMode);
}
- for (final Entry<ValidationBundleType, Collection<?>> validationBundle : supportedValidation.entrySet()) {
- addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
- }
+ addToNamespace(ValidationBundlesNamespace.class, supportedValidation);
this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
}
return enabledSemanticVersions;
}
- StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase currentPhase) {
- return supports.get(currentPhase);
+ StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase phase) {
+ return supports.get(phase);
}
- void addSource(@Nonnull final StatementStreamSource source) {
+ void addSource(final @NonNull StatementStreamSource source) {
sources.add(new SourceSpecificContext(this, source));
}
- void addLibSource(@Nonnull final StatementStreamSource libSource) {
+ void addLibSource(final @NonNull StatementStreamSource libSource) {
checkState(!isEnabledSemanticVersioning(),
"Library sources are not supported in semantic version mode currently.");
checkState(currentPhase == ModelProcessingPhase.INIT,
}
void setSupportedFeatures(final Set<QName> supportedFeatures) {
- addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
+ addToNamespace(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
ImmutableSet.copyOf(supportedFeatures));
}
- void setModulesDeviatedByModules(final Map<QNameModule, Set<QNameModule>> modulesDeviatedByModules) {
- addToNs(ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES,
- ImmutableMap.copyOf(modulesDeviatedByModules));
+ void setModulesDeviatedByModules(final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules) {
+ addToNamespace(ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES,
+ ImmutableSetMultimap.copyOf(modulesDeviatedByModules));
}
@Override
}
}
- EffectiveModelContext build() throws ReactorException {
+ ReactorDeclaredModel build() throws ReactorException {
executePhases();
return transform();
}
return transformEffective();
}
- private EffectiveModelContext transform() {
+ private ReactorDeclaredModel transform() {
checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL);
final List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size());
for (final SourceSpecificContext source : sources) {
rootStatements.add(source.getRoot().buildDeclared());
}
- return new EffectiveModelContext(rootStatements);
+ return new ReactorDeclaredModel(rootStatements);
}
private SomeModifiersUnresolvedException propagateException(final SourceSpecificContext source,
}
@SuppressWarnings("checkstyle:illegalCatch")
- private void loadPhaseStatementsFor(final Set<SourceSpecificContext> sources) throws ReactorException {
- for (final SourceSpecificContext source : sources) {
+ private void loadPhaseStatementsFor(final Set<SourceSpecificContext> srcs) throws ReactorException {
+ for (final SourceSpecificContext source : srcs) {
try {
source.loadStatements();
} catch (final RuntimeException ex) {
SomeModifiersUnresolvedException buildFailure = null;
for (final SourceSpecificContext failedSource : sourcesToProgress) {
final Optional<SourceException> optSourceEx = failedSource.failModifiers(currentPhase);
- if (!optSourceEx.isPresent()) {
+ if (optSourceEx.isEmpty()) {
continue;
}
int count = 1;
for (final Throwable t : suppressed) {
- // FIXME: this should be configured in the appender, really
- if (LOG.isDebugEnabled()) {
- LOG.error("Error {}: {}", count, t.getMessage(), t);
- } else {
- LOG.error("Error {}: {}", count, t.getMessage());
- }
-
+ LOG.error("Error {}: {}", count, t.getMessage());
count++;
}
}