Brings down the number of violations to under 700.
Change-Id: I8da94e59b13fa109832b6d903045c352ad47786c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-public abstract class AbstractYangTextSchemaSourceRegistration extends AbstractObjectRegistration<YangTextSchemaSource> implements YangTextSchemaSourceRegistration {
+public abstract class AbstractYangTextSchemaSourceRegistration extends AbstractObjectRegistration<YangTextSchemaSource>
+ implements YangTextSchemaSourceRegistration {
protected AbstractYangTextSchemaSourceRegistration(final YangTextSchemaSource instance) {
super(instance);
}
* corresponding dependency information, the {@link #create(Map)} method creates a
* a view of how consistent the dependencies are. In particular, this detects whether
* any imports are unsatisfied.
- *
- * FIXME: improve this class to track and expose how wildcard imports were resolved.
- * That information will allow us to track "damage" to dependency resolution
- * as new models are added to a schema context.
*/
+// FIXME: improve this class to track and expose how wildcard imports were resolved.
+// That information will allow us to track "damage" to dependency resolution
+// as new models are added to a schema context.
abstract class DependencyResolver {
private static final Logger LOG = LoggerFactory.getLogger(DependencyResolver.class);
private final Collection<SourceIdentifier> resolvedSources;
this.unsatisfiedImports = ImmutableMultimap.copyOf(imports);
}
- abstract protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi);
+ protected abstract boolean isKnown(Collection<SourceIdentifier> haystack, ModuleImport mi);
/**
* Collection of sources which have been resolved.
- *
- * @return
*/
Collection<SourceIdentifier> getResolvedSources() {
return resolvedSources;
/**
* Collection of sources which have not been resolved due to missing dependencies.
- *
- * @return
*/
Collection<SourceIdentifier> getUnresolvedSources() {
return unresolvedSources;
* is the source identifier of module which was issuing an import, the values
* are imports which were unsatisfied.
*
+ * <p>
* Note that this map contains only imports which are missing from the reactor,
* not transitive failures.
*
+ * <p>
* Examples:
- *
+ * <ul><li>
* If A imports B, B imports C, and both A and B are in the reactor, only B->C
* will be reported.
- *
+ * </li><li>
* If A imports B and C, B imports C, and both A and B are in the reactor,
* A->C and B->C will be reported.
- *
- * @return
+ * </li></ul>
*/
Multimap<SourceIdentifier, ModuleImport> getUnsatisfiedImports() {
return unsatisfiedImports;
private static class BelongsToDependency implements ModuleImport {
private final String parent;
- public BelongsToDependency(final String parent) {
+ BelongsToDependency(final String parent) {
this.parent = parent;
}
super(depInfo);
}
- protected static SourceIdentifier findCompatibleVersion(final Iterable<SourceIdentifier> haystack, final ModuleImport mi) {
+ protected static SourceIdentifier findCompatibleVersion(final Iterable<SourceIdentifier> haystack,
+ final ModuleImport mi) {
final String requestedModuleName = mi.getModuleName();
for (SourceIdentifier r : haystack) {
if (requestedModuleName.equals(r.getName())
@Override
protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi) {
final String rev = mi.getRevision() != null ? QName.formattedRevision(mi.getRevision()) : null;
- final SemVerSourceIdentifier msi = SemVerSourceIdentifier.create(mi.getModuleName(), Optional.fromNullable(rev), mi.getSemanticVersion());
+ final SemVerSourceIdentifier msi = SemVerSourceIdentifier.create(mi.getModuleName(), Optional.fromNullable(rev),
+ mi.getSemanticVersion());
// Quick lookup
if (haystack.contains(msi)) {
public static SemVerDependencyResolver create(final Map<SourceIdentifier, YangModelDependencyInfo> depInfo) {
return new SemVerDependencyResolver(depInfo);
}
-}
\ No newline at end of file
+}
// FIXME SchemaRepository should be the type for repository parameter instead of SharedSchemaRepository
// (final implementation)
- public SharedSchemaContextFactory(final SharedSchemaRepository repository, final SchemaSourceFilter filter) {
+ SharedSchemaContextFactory(final SharedSchemaRepository repository, final SchemaSourceFilter filter) {
this.repository = Preconditions.checkNotNull(repository);
this.filter = Preconditions.checkNotNull(filter);
}
new AssembleSources(Optional.ofNullable(supportedFeatures), statementParserMode));
}
- private ListenableFuture<ASTSchemaSource> requestSource(final SourceIdentifier identifier) {
- return repository.getSchemaSource(identifier, ASTSchemaSource.class);
- }
-
private CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
final Collection<SourceIdentifier> requiredSources,
final Cache<Collection<SourceIdentifier>, SchemaContext> cache,
}
@Override
- public void onFailure(@Nonnull final Throwable t) {
- LOG.debug("Failed to assemble sources", t);
+ public void onFailure(@Nonnull final Throwable cause) {
+ LOG.debug("Failed to assemble sources", cause);
}
}, MoreExecutors.directExecutor());
return Futures.makeChecked(cf, MAPPER);
}
+ private ListenableFuture<ASTSchemaSource> requestSource(final SourceIdentifier identifier) {
+ return repository.getSchemaSource(identifier, ASTSchemaSource.class);
+ }
+
/**
+ * Return a set of de-duplicated inputs.
+ *
* @return set (preserving ordering) from the input collection
*/
private static List<SourceIdentifier> deDuplicateSources(final Collection<SourceIdentifier> requiredSources) {
List<ASTSchemaSource>> {
private final List<SourceIdentifier> sourceIdentifiers;
- public SourceIdMismatchDetector(final List<SourceIdentifier> sourceIdentifiers) {
+ SourceIdMismatchDetector(final List<SourceIdentifier> sourceIdentifiers) {
this.sourceIdentifiers = Preconditions.checkNotNull(sourceIdentifiers);
}
this.supportedFeatures = supportedFeatures;
this.statementParserMode = Preconditions.checkNotNull(statementParserMode);
switch (statementParserMode) {
- case SEMVER_MODE:
- this.getIdentifier = ASTSchemaSource::getSemVerIdentifier;
- break;
- default:
- this.getIdentifier = ASTSchemaSource::getIdentifier;
+ case SEMVER_MODE:
+ this.getIdentifier = ASTSchemaSource::getSemVerIdentifier;
+ break;
+ default:
+ this.getIdentifier = ASTSchemaSource::getIdentifier;
}
}
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.util.AbstractSchemaRepository;
/**
- * A {@link SchemaRepository} which allows sharing of {@link SchemaContext} as
- * long as their specification is the same.
+ * A {@link SchemaRepository} which allows sharing of {@link SchemaContext} as long as their specification is the same.
*
- * Note: for current implementation, "same" means the same filter and the same
- * set of {@link SourceIdentifier}s.
+ * <p>
+ * Note: for current implementation, "same" means the same filter and the same set of {@link SourceIdentifier}s.
*/
@Beta
public final class SharedSchemaRepository extends AbstractSchemaRepository implements Identifiable<String> {
* Register a {@link YangTextSchemaSource}.
*
* @param source YANG text source
+ * @return a YangTextSchemaSourceRegistration
* @throws YangSyntaxErrorException When the YANG file is syntactically invalid
* @throws IOException when the URL is not readable
* @throws SchemaSourceException When parsing encounters general error
- * @return a YangTextSchemaSourceRegistration
*/
public YangTextSchemaSourceRegistration registerSource(@Nonnull final YangTextSchemaSource source)
throws SchemaSourceException, IOException, YangSyntaxErrorException {
* Register a URL containing a YANG text.
*
* @param url YANG text source URL
+ * @return a YangTextSchemaSourceRegistration for this URL
* @throws YangSyntaxErrorException When the YANG file is syntactically invalid
* @throws IOException when the URL is not readable
* @throws SchemaSourceException When parsing encounters general error
- * @return a YangTextSchemaSourceRegistration for this URL
*/
public YangTextSchemaSourceRegistration registerSource(@Nonnull final URL url) throws SchemaSourceException,
IOException, YangSyntaxErrorException {
/**
* Try to parse all currently available yang files and build new schema context.
+ *
* @return new schema context iif there is at least 1 yang file registered and
* new schema context was successfully built.
*/
}
/**
- * Try to parse all currently available yang files and build new schema context
- * in dependence on specified parsing mode.
+ * Try to parse all currently available yang files and build new schema context depending on specified parsing mode.
*
* @param statementParserMode mode of statement parser
* @return new schema context iif there is at least 1 yang file registered and
public Optional<SchemaContext> getSchemaContext(final StatementParserMode statementParserMode) {
final SchemaContextFactory factory = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
Optional<SchemaContext> sc;
- Object v;
+ Object ver;
do {
// Spin get stable context version
Object cv;
// Version has been updated
Collection<SourceIdentifier> sources;
do {
- v = version;
+ ver = version;
sources = ImmutableSet.copyOf(requiredSources);
- } while (v != version);
+ } while (ver != version);
while (true) {
final CheckedFuture<SchemaContext, SchemaResolutionException> f = factory.createSchemaContext(sources,
synchronized (this) {
if (contextVersion == cv) {
currentSchemaContext.set(sc);
- contextVersion = v;
+ contextVersion = ver;
}
}
- } while (version == v);
+ } while (version == ver);
return sc;
}
}
@Override
- public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) {
+ @SuppressWarnings("checkstyle:parameterName")
+ public void startElement(final String uri, final String localName, final String qName,
+ final Attributes attributes) {
addTextIfNeeded();
final Element el = doc.createElementNS(uri, qName);
for (int i = 0, len = attributes.getLength(); i < len; i++) {
sb.setLength(0);
}
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBehaviour.Registry {
+class BuildGlobalContext extends NamespaceStorageSupport implements Registry {
private static final Logger LOG = LoggerFactory.getLogger(BuildGlobalContext.class);
- private static final List<ModelProcessingPhase> PHASE_EXECUTION_ORDER = ImmutableList
- .<ModelProcessingPhase> builder().add(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
+ private static final List<ModelProcessingPhase> PHASE_EXECUTION_ORDER =
+ ImmutableList.<ModelProcessingPhase>builder().add(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
.add(ModelProcessingPhase.SOURCE_LINKAGE).add(ModelProcessingPhase.STATEMENT_DEFINITION)
.add(ModelProcessingPhase.FULL_DECLARATION).add(ModelProcessingPhase.EFFECTIVE_MODEL).build();
switch (sourceProgress) {
case FINISHED:
currentSource.remove();
- // Fallback to progress, since we were able to make
- // progress in computation
+ // we were able to make progress in computation
+ progressing = true;
+ break;
case PROGRESS:
progressing = true;
break;
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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class CrossSourceStatementReactor {
- private static final Logger LOG = LoggerFactory.getLogger(CrossSourceStatementReactor.class);
-
private final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology;
private final Map<ValidationBundleType, Collection<?>> supportedValidation;
* @return A new {@link BuildAction}.
* @throws NullPointerException if statementParserMode is null
*
- * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures()
- * on the created BuildAction instead.
+ * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures() on the created
+ * BuildAction instead.
*/
@Deprecated
public BuildAction newBuild(final StatementParserMode statementParserMode,
* @return A new {@link BuildAction}.
* @throws NullPointerException if statementParserMode is null
*
- * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures()
- * on the created BuildAction instead.
+ * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures() on the created
+ * BuildAction instead.
*/
@Deprecated
public BuildAction newBuild(final StatementParserMode statementParserMode,
}
/**
- * Add main source. All main sources are present in resulting
- * SchemaContext.
+ * Add main source. All main sources are present in resulting SchemaContext.
*
* @param source
* which should be added into main sources
}
/**
- * Add main sources. All main sources are present in resulting
- * SchemaContext.
+ * Add main sources. All main sources are present in resulting SchemaContext.
*
* @param sources
* which should be added into main sources
}
/**
- * Add library sources. Only library sources required by main sources
- * are present in resulting SchemaContext. Any other library sources are
- * ignored and this also applies to error reporting.
+ * Add library sources. Only library sources required by main sources are present in resulting SchemaContext.
+ * Any other library sources are ignored and this also applies to error reporting.
*
+ * <p>
* Library sources are not supported in semantic version mode currently.
*
* @param libSources
}
/**
- * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException
- * @throws ReactorException
+ * Build the effective model context.
*/
public EffectiveModelContext build() throws ReactorException {
return context.build();
}
/**
+ * Add specified sources and assemble the resulting SchemaContext.
+ *
* @deprecated Use {@link #addSources(Collection)} and {@link #buildEffective()} instead.
*/
@Deprecated
}
/**
+ * Add specified sources and assemble the resulting SchemaContext.
+ *
* @deprecated Use {@link #addSources(Collection)} and {@link #buildEffective()} instead.
*/
@Deprecated
return buildEffective();
}
}
-}
\ No newline at end of file
+}
}
/**
+ * Resolve SchemaContext for a set of modules.
+ *
* @deprecated Use {@link SimpleSchemaContext#forModules(Set)} instead.
*/
@Deprecated
public static SchemaContext resolveSchemaContext(final Set<Module> modules) {
- return SimpleSchemaContext.forModules(modules);
+ return SimpleSchemaContext.forModules(modules);
}
@VisibleForTesting
Preconditions.checkState(action == null, "Action was already registered.");
}
- private static IllegalStateException shouldNotHappenProbablyBug(final SourceException e) {
- return new IllegalStateException("Source exception during registering prerequisite. This is probably bug.", e);
+ private static IllegalStateException shouldNotHappenProbablyBug(final SourceException cause) {
+ return new IllegalStateException("Source exception during registering prerequisite. This is probably bug.",
+ cause);
}
private boolean removeSatisfied() {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
- private <K, C extends StmtContext.Mutable<?, ?, ?> , N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>>
- AbstractPrerequisite<C> mutatesCtxImpl(final StmtContext<?, ?, ?> context, final Class<N> namespace,
- final K key, final ModelProcessingPhase phase) {
+ private <K, C extends StmtContext.Mutable<?, ?, ?>,
+ N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<C> mutatesCtxImpl(
+ final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key,
+ final ModelProcessingPhase phase) {
checkNotRegistered();
try {
}
private static StatementContextBase<?,?,?> contextImpl(final Object value) {
- Preconditions.checkArgument(value instanceof StatementContextBase,"Supplied context was not provided by this reactor.");
+ Preconditions.checkArgument(value instanceof StatementContextBase,
+ "Supplied context %s is not provided by this reactor.", value);
return StatementContextBase.class.cast(value);
}
@Nonnull
@Override
- public <C extends Mutable<?, ?, ?>, CT extends C> Prerequisite<C> mutatesCtx(final CT context, final ModelProcessingPhase phase) {
+ public <C extends Mutable<?, ?, ?>, CT extends C> Prerequisite<C> mutatesCtx(final CT context,
+ final ModelProcessingPhase phase) {
try {
return addMutation(new PhaseMutation<>(contextImpl(context), phase));
} catch (InferenceException e) {
@Nonnull
@Override
- public <A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> AbstractPrerequisite<StmtContext<A, D, E>> requiresCtx(final StmtContext<A, D, E> context, final ModelProcessingPhase phase) {
+ public <A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>>
+ AbstractPrerequisite<StmtContext<A, D, E>> requiresCtx(final StmtContext<A, D, E> context,
+ final ModelProcessingPhase phase) {
return requiresCtxImpl(context, phase);
}
@Nonnull
@Override
- public <K, N extends StatementNamespace<K, ?, ? >> Prerequisite<StmtContext<?,?,?>> requiresCtx(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key, final ModelProcessingPhase phase) {
+ public <K, N extends StatementNamespace<K, ?, ?>> Prerequisite<StmtContext<?, ?, ?>> requiresCtx(
+ final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key,
+ final ModelProcessingPhase phase) {
return requiresCtxImpl(context, namespace, key, phase);
}
@Nonnull
@Override
- public <D extends DeclaredStatement<?>> Prerequisite<D> requiresDeclared(final StmtContext<?, ? extends D, ?> context) {
+ public <D extends DeclaredStatement<?>> Prerequisite<D> requiresDeclared(
+ final StmtContext<?, ? extends D, ?> context) {
return requiresCtxImpl(context, FULL_DECLARATION).transform(StmtContext::buildDeclared);
}
@Nonnull
@Override
- public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> AbstractPrerequisite<StmtContext<?, D, ?>> requiresDeclaredCtx(
- final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
- return requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
+ public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> Prerequisite<D>
+ requiresDeclared(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
+ final AbstractPrerequisite<StmtContext<?, D, ?>> rawContext = requiresCtxImpl(context, namespace, key,
+ FULL_DECLARATION);
+ return rawContext.transform(StmtContext::buildDeclared);
}
@Nonnull
@Override
- public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> Prerequisite<D> requiresDeclared(
- final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
- final AbstractPrerequisite<StmtContext<?, D, ?>> rawContext = requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
- return rawContext.transform(StmtContext::buildDeclared);
+ public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>>
+ AbstractPrerequisite<StmtContext<?, D, ?>> requiresDeclaredCtx(final StmtContext<?, ?, ?> context,
+ final Class<N> namespace, final K key) {
+ return requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
}
@Nonnull
@Override
- public <E extends EffectiveStatement<?, ?>> Prerequisite<E> requiresEffective(final StmtContext<?, ?, ? extends E> stmt) {
+ public <E extends EffectiveStatement<?, ?>> Prerequisite<E> requiresEffective(
+ final StmtContext<?, ?, ? extends E> stmt) {
return requiresCtxImpl(stmt, EFFECTIVE_MODEL).transform(StmtContext::buildEffective);
}
@Nonnull
@Override
- public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> AbstractPrerequisite<StmtContext<?, ?, E>> requiresEffectiveCtx(
- final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
- return requiresCtxImpl(contextImpl(context), namespace, key, EFFECTIVE_MODEL);
+ public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<E>
+ requiresEffective(final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
+ final AbstractPrerequisite<StmtContext<?,?,E>> rawContext = requiresCtxImpl(context, namespace, key,
+ EFFECTIVE_MODEL);
+ return rawContext.transform(StmtContext::buildEffective);
}
@Nonnull
@Override
- public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<E> requiresEffective(
- final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
- final AbstractPrerequisite<StmtContext<?,?,E>> rawContext = requiresCtxImpl(context, namespace, key, EFFECTIVE_MODEL);
- return rawContext.transform(StmtContext::buildEffective);
+ public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>>
+ AbstractPrerequisite<StmtContext<?, ?, E>> requiresEffectiveCtx(final StmtContext<?, ?, ?> context,
+ final Class<N> namespace, final K key) {
+ return requiresCtxImpl(contextImpl(context), namespace, key, EFFECTIVE_MODEL);
}
-
@Nonnull
@Override
- public <N extends IdentifierNamespace<?, ?>> Prerequisite<Mutable<?, ?, ?>> mutatesNs(final Mutable<?, ?, ?> context,
- final Class<N> namespace) {
+ public <N extends IdentifierNamespace<?, ?>> Prerequisite<Mutable<?, ?, ?>> mutatesNs(
+ final Mutable<?, ?, ?> context, final Class<N> namespace) {
try {
return addMutation(new NamespaceMutation<>(contextImpl(context), namespace));
} catch (SourceException e) {
@Nonnull
@Override
- public <K, E extends EffectiveStatement<?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<Mutable<?, ?, E>> mutatesEffectiveCtx(
- final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
+ public <K, E extends EffectiveStatement<?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>>
+ AbstractPrerequisite<Mutable<?, ?, E>> mutatesEffectiveCtx(final StmtContext<?, ?, ?> context,
+ final Class<N> namespace, final K key) {
return mutatesCtxImpl(context, namespace, key, EFFECTIVE_MODEL);
}
}
private abstract class AbstractPrerequisite<T> implements Prerequisite<T> {
-
private boolean done = false;
private T value;
private class PhaseMutation<C> extends AbstractPrerequisite<C> implements ContextMutation {
@SuppressWarnings("unchecked")
- public PhaseMutation(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) {
+ PhaseMutation(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) {
context.addMutation(phase, this);
resolvePrereq((C) context);
}
}
}
- private class PhaseFinished<C extends StmtContext<?, ?, ?>> extends AbstractPrerequisite<C> implements OnPhaseFinished {
+ private class PhaseFinished<C extends StmtContext<?, ?, ?>> extends AbstractPrerequisite<C>
+ implements OnPhaseFinished {
@SuppressWarnings("unchecked")
@Override
public boolean phaseFinished(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) {
}
}
- private class NamespaceMutation<N extends IdentifierNamespace<?,?>> extends AbstractPrerequisite<StmtContext.Mutable<?, ?, ?>> {
- public NamespaceMutation(final StatementContextBase<?, ?, ?> ctx, final Class<N> namespace) {
+ private class NamespaceMutation<N extends IdentifierNamespace<?,?>>
+ extends AbstractPrerequisite<Mutable<?, ?, ?>> {
+ NamespaceMutation(final StatementContextBase<?, ?, ?> ctx, final Class<N> namespace) {
resolvePrereq(ctx);
}
}
- private class AddedToNamespace<C extends StmtContext<?,?,?>> extends AbstractPrerequisite<C> implements OnNamespaceItemAdded,OnPhaseFinished {
+ private class AddedToNamespace<C extends StmtContext<?,?,?>> extends AbstractPrerequisite<C>
+ implements OnNamespaceItemAdded, OnPhaseFinished {
private final ModelProcessingPhase phase;
- public <K, N extends StatementNamespace<K, ?, ?>> AddedToNamespace(final ModelProcessingPhase phase) {
+ AddedToNamespace(final ModelProcessingPhase phase) {
this.phase = phase;
}
@Override
- public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace, final Object key,
- final Object value) {
- StatementContextBase<?, ?, ?> targetContext = (StatementContextBase<?, ?, ?>) value;
- targetContext.addPhaseCompletedListener(phase, this);
+ public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace,
+ final Object key, final Object value) {
+ ((StatementContextBase<?, ?, ?>) value).addPhaseCompletedListener(phase, this);
}
@SuppressWarnings("unchecked")
}
}
- private class PhaseModificationInNamespace<C extends Mutable<?,?,?>> extends AbstractPrerequisite<C> implements OnNamespaceItemAdded, ContextMutation {
+ private class PhaseModificationInNamespace<C extends Mutable<?,?,?>> extends AbstractPrerequisite<C>
+ implements OnNamespaceItemAdded, ContextMutation {
private final ModelProcessingPhase modPhase;
- public <K, N extends StatementNamespace<K, ?, ?>> PhaseModificationInNamespace(final ModelProcessingPhase phase) {
+ PhaseModificationInNamespace(final ModelProcessingPhase phase) {
Preconditions.checkArgument(phase != null, "Model processing phase must not be null");
this.modPhase = phase;
}
@SuppressWarnings("unchecked")
@Override
- public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace, final Object key,
- final Object value) {
+ public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace,
+ final Object key, final Object value) {
StatementContextBase<?, ?, ?> targetCtx = contextImpl(value);
targetCtx.addMutation(modPhase, this);
resolvePrereq((C) targetCtx);
private final NamespaceStorageNode ctxNode;
private final K key;
- public ValueAddedListener(final NamespaceStorageNode contextNode, final K key) {
+ ValueAddedListener(final NamespaceStorageNode contextNode, final K key) {
this.ctxNode = contextNode;
this.key = key;
}
protected final NamespaceBehaviour<K, V, N> delegate;
private final List<VirtualNamespaceContext<?, V, ?, K>> derivedNamespaces = new ArrayList<>();
-
protected NamespaceBehaviourWithListeners(final NamespaceBehaviour<K, V, N> delegate) {
super(delegate.getIdentifier());
this.delegate = delegate;
protected abstract boolean isRequestedValue(ValueAddedListener<K> listener, NamespaceStorageNode storage, V value);
@Override
- public abstract void addTo(final NamespaceStorageNode storage, final K key, final V value);
+ public abstract void addTo(NamespaceStorageNode storage, K key, V value);
- protected void notifyListeners(final NamespaceStorageNode storage, final Iterator<ValueAddedListener<K>> keyListeners,
- final V value) {
+ protected void notifyListeners(final NamespaceStorageNode storage,
+ final Iterator<ValueAddedListener<K>> keyListeners, final V value) {
List<ValueAddedListener<K>> toNotify = new ArrayList<>();
while (keyListeners.hasNext()) {
ValueAddedListener<K> listener = keyListeners.next();
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
public abstract NamespaceStorageNode getParentNamespaceStorage();
/**
+ * Return the registry of a source context.
+ *
* @return registry of source context
*/
- public abstract NamespaceBehaviour.Registry getBehaviourRegistry();
+ public abstract Registry getBehaviourRegistry();
protected void checkLocalNamespaceAllowed(final Class<? extends IdentifierNamespace<?, ?>> type) {
// NOOP
@Nonnull
public final <K,V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(final Class<N> type,
final KT key) throws NamespaceNotAvailableException {
- return getBehaviourRegistry().getNamespaceBehaviour(type).getFrom(this,key);
+ return getBehaviourRegistry().getNamespaceBehaviour(type).getFrom(this, key);
}
- public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(final Class<N> type){
+ public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(final Class<N> type) {
return getBehaviourRegistry().getNamespaceBehaviour(type).getAllFrom(this);
}
this.setRootIdentifier(identifier);
}
- /**
- * @return null as root cannot have parent
- */
@Override
public StatementContextBase<?, ?, ?> getParentContext() {
+ // null as root cannot have parent
return null;
}
- /**
- * @return namespace storage of source context
- */
@Override
public NamespaceStorageNode getParentNamespaceStorage() {
+ // namespace storage of source context
return sourceContext;
}
public StorageNodeType getStorageNodeType() {
return StorageNodeType.ROOT_STATEMENT_LOCAL;
}
- /**
- * @return this as its own root
- */
+
@Nonnull
@Override
public RootStatementContext<?, ?, ?> getRoot() {
+ // this as its own root
return this;
}
}
private static final Logger LOG = LoggerFactory.getLogger(SourceSpecificContext.class);
+
private final Multimap<ModelProcessingPhase, ModifierImpl> modifiers = HashMultimap.create();
- private final QNameToStatementDefinitionMap qNameToStmtDefMap = new QNameToStatementDefinitionMap();
+ private final QNameToStatementDefinitionMap qnameToStmtDefMap = new QNameToStatementDefinitionMap();
private final PrefixToModuleMap prefixToModuleMap = new PrefixToModuleMap();
private final BuildGlobalContext currentContext;
private final StatementStreamSource source;
this.source = Preconditions.checkNotNull(source);
}
- boolean isEnabledSemanticVersioning(){
+ boolean isEnabledSemanticVersioning() {
return currentContext.isEnabledSemanticVersioning();
}
if (def == null) {
def = currentContext.getModelDefinedStatementDefinition(name);
if (def == null) {
- final StatementSupport<?, ?, ?> extension = qNameToStmtDefMap.get(name);
+ final StatementSupport<?, ?, ?> extension = qnameToStmtDefMap.get(name);
if (extension != null) {
def = new StatementDefinitionContext<>(extension);
currentContext.putModelDefinedStatementDefinition(name, def);
root = new RootStatementContext<>(this, def, ref, argument);
} else if (!RootStatementContext.DEFAULT_VERSION.equals(root.getRootVersion())
&& inProgressPhase == ModelProcessingPhase.SOURCE_LINKAGE) {
- root = new RootStatementContext<>(this, def, ref, argument, root.getRootVersion(), root.getRootIdentifier());
+ root = new RootStatementContext<>(this, def, ref, argument, root.getRootVersion(),
+ root.getRootIdentifier());
} else {
final QName rootStatement = root.definition().getStatementName();
final String rootArgument = root.rawStatementArgument();
Preconditions.checkState(Objects.equals(def.getStatementName(), rootStatement)
- && Objects.equals(argument, rootArgument),
- "Root statement was already defined as '%s %s'.", rootStatement, rootArgument);
+ && Objects.equals(argument, rootArgument), "Root statement was already defined as '%s %s'.",
+ rootStatement, rootArgument);
}
return root;
}
final Collection<ModifierImpl> previousModifiers = modifiers.get(previousPhase);
Preconditions.checkState(previousModifiers.isEmpty(),
- "Previous phase %s has unresolved modifiers %s in source %s",
- previousPhase, previousModifiers, source);
+ "Previous phase %s has unresolved modifiers %s in source %s", previousPhase, previousModifiers, source);
inProgressPhase = phase;
LOG.debug("Source {} started phase {}", source, phase);
source.writePreLinkage(new StatementContextWriter(this, inProgressPhase), stmtDef());
break;
case SOURCE_LINKAGE:
- source.writeLinkage(new StatementContextWriter(this, inProgressPhase), stmtDef(), preLinkagePrefixes(), getRootVersion());
+ source.writeLinkage(new StatementContextWriter(this, inProgressPhase), stmtDef(), preLinkagePrefixes(),
+ getRootVersion());
break;
case STATEMENT_DEFINITION:
- source.writeLinkageAndStatementDefinitions(new StatementContextWriter(this, inProgressPhase), stmtDef(), prefixes(), getRootVersion());
+ source.writeLinkageAndStatementDefinitions(new StatementContextWriter(this, inProgressPhase), stmtDef(),
+ prefixes(), getRootVersion());
break;
case FULL_DECLARATION:
- source.writeFull(new StatementContextWriter(this, inProgressPhase), stmtDef(), prefixes(), getRootVersion());
+ source.writeFull(new StatementContextWriter(this, inProgressPhase), stmtDef(), prefixes(),
+ getRootVersion());
break;
default:
break;
}
private PrefixToModule prefixes() {
- final Map<String, ModuleIdentifier> allPrefixes = getRoot().getAllFromNamespace(ImpPrefixToModuleIdentifier
- .class);
- final Map<String, ModuleIdentifier> belongsToPrefixes = getRoot().getAllFromNamespace
- (BelongsToPrefixToModuleIdentifier.class);
+ final Map<String, ModuleIdentifier> allPrefixes = getRoot().getAllFromNamespace(
+ ImpPrefixToModuleIdentifier.class);
+ final Map<String, ModuleIdentifier> belongsToPrefixes = getRoot().getAllFromNamespace(
+ BelongsToPrefixToModuleIdentifier.class);
if (belongsToPrefixes != null) {
allPrefixes.putAll(belongsToPrefixes);
}
private QNameToStatementDefinition stmtDef() {
// regular YANG statements and extension supports added
final StatementSupportBundle supportsForPhase = currentContext.getSupportsForPhase(inProgressPhase);
- qNameToStmtDefMap.putAll(supportsForPhase.getCommonDefinitions());
- qNameToStmtDefMap.putAll(supportsForPhase.getDefinitionsSpecificForVersion(getRootVersion()));
+ qnameToStmtDefMap.putAll(supportsForPhase.getCommonDefinitions());
+ qnameToStmtDefMap.putAll(supportsForPhase.getDefinitionsSpecificForVersion(getRootVersion()));
// No further actions needed
if (inProgressPhase != ModelProcessingPhase.FULL_DECLARATION) {
- return qNameToStmtDefMap;
+ return qnameToStmtDefMap;
}
// We need to any and all extension statements which have been declared in the context
StatementDefinitionNamespace.class);
if (extensions != null) {
extensions.forEach((qname, support) -> {
- final StatementSupport<?, ?, ?> existing = qNameToStmtDefMap.putIfAbsent(qname, support);
+ final StatementSupport<?, ?, ?> existing = qnameToStmtDefMap.putIfAbsent(qname, support);
if (existing != null) {
LOG.debug("Source {} already defines statement {} as {}", source, qname, existing);
} else {
});
}
- return qNameToStmtDefMap;
+ return qnameToStmtDefMap;
}
public Set<YangVersion> getSupportedVersions() {
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.ImplicitSubstatement;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.slf4j.LoggerFactory;
public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
- extends NamespaceStorageSupport implements StmtContext.Mutable<A, D, E> {
+ extends NamespaceStorageSupport implements Mutable<A, D, E> {
/**
- * event listener when an item is added to model namespace.
+ * Event listener when an item is added to model namespace.
*/
interface OnNamespaceItemAdded extends EventListener {
/**
- * @throws SourceException
+ * Invoked whenever a new item is added to a namespace.
*/
void namespaceItemAdded(StatementContextBase<?, ?, ?> context, Class<?> namespace, Object key, Object value);
}
/**
- * event listener when a parsing {@link ModelProcessingPhase} is completed.
+ * Event listener when a parsing {@link ModelProcessingPhase} is completed.
*/
interface OnPhaseFinished extends EventListener {
/**
- * @throws SourceException
+ * Invoked whenever a processing phase has finished.
*/
boolean phaseFinished(StatementContextBase<?, ?, ?> context, ModelProcessingPhase phase);
}
/**
- * interface for all mutations within an {@link ModelActionBuilder.InferenceAction}.
+ * Interface for all mutations within an {@link ModelActionBuilder.InferenceAction}.
*/
interface ContextMutation {
public abstract StatementContextBase<?, ?, ?> getParentContext();
/**
+ * Returns the model root for this statement.
+ *
* @return root context of statement
*/
@Nonnull
public abstract RootStatementContext<?, ?, ?> getRoot();
/**
+ * Returns the origin of the statement.
+ *
* @return origin of statement
*/
@Nonnull
}
/**
+ * Returns a reference to statement source.
+ *
* @return reference of statement source
*/
@Nonnull
return Collections.unmodifiableCollection(effective);
}
- public void removeStatementsFromEffectiveSubstatements(final Collection<? extends StmtContext<?, ?, ?>> substatements) {
+ public void removeStatementsFromEffectiveSubstatements(
+ final Collection<? extends StmtContext<?, ?, ?>> substatements) {
if (!effective.isEmpty()) {
effective.removeAll(substatements);
shrinkEffective();
}
/**
- * Removes a statement context from the effective substatements
- * based on its statement definition (i.e statement keyword) and raw (in String form) statement argument.
- * The statement context is removed only if both statement definition and statement argument match with
- * one of the effective substatements' statement definition and argument.
+ * Removes a statement context from the effective substatements based on its statement definition (i.e statement
+ * keyword) and raw (in String form) statement argument. The statement context is removed only if both statement
+ * definition and statement argument match with one of the effective substatements' statement definition
+ * and argument.
*
+ * <p>
* If the statementArg parameter is null, the statement context is removed based only on its statement definition.
*
* @param statementDef statement definition of the statement context to remove
}
/**
- * adds effective statement to collection of substatements
+ * Adds an effective statement to collection of substatements.
*
* @param substatement substatement
* @throws IllegalStateException
}
/**
- * adds effective statement to collection of substatements
+ * Adds an effective statement to collection of substatements.
*
* @param substatements substatements
* @throws IllegalStateException
* @param argument statement argument
* @return A new substatement
*/
- public final <CA, CD extends DeclaredStatement<CA>, CE extends EffectiveStatement<CA, CD>> StatementContextBase<CA, CD, CE> createSubstatement(
- final int offset, final StatementDefinitionContext<CA, CD, CE> def, final StatementSourceReference ref,
- final String argument) {
+ public final <CA, CD extends DeclaredStatement<CA>, CE extends EffectiveStatement<CA, CD>>
+ StatementContextBase<CA, CD, CE> createSubstatement(final int offset,
+ final StatementDefinitionContext<CA, CD, CE> def, final StatementSourceReference ref,
+ final String argument) {
final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
Preconditions.checkState(inProgressPhase != ModelProcessingPhase.EFFECTIVE_MODEL,
"Declared statement cannot be added in effective phase at: %s", getStatementSourceReference());
/**
* Ends declared section of current node.
- *
- * @param ref
- * @throws SourceException
*/
void endDeclared(final StatementSourceReference ref, final ModelProcessingPhase phase) {
definition().onDeclarationFinished(this, phase);
}
/**
+ * Return the context in which this statement was defined.
+ *
* @return statement definition
*/
protected final StatementDefinitionContext<A, D, E> definition() {
}
/**
- * adds {@link OnPhaseFinished} listener for a {@link ModelProcessingPhase} end
- *
- * @throws SourceException
+ * Adds {@link OnPhaseFinished} listener for a {@link ModelProcessingPhase} end.
*/
void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) {
-
Preconditions.checkNotNull(phase, "Statement context processing phase cannot be null at: %s",
getStatementSourceReference());
Preconditions.checkNotNull(listener, "Statement context phase listener cannot be null at: %s",
}
/**
- * adds {@link ContextMutation} to {@link ModelProcessingPhase}
+ * Adds a {@link ContextMutation} to a {@link ModelProcessingPhase}.
*
* @throws IllegalStateException
* when the mutation was registered after phase was completed
void addMutation(final ModelProcessingPhase phase, final ContextMutation mutation) {
ModelProcessingPhase finishedPhase = completedPhase;
while (finishedPhase != null) {
- if (phase.equals(finishedPhase)) {
- throw new IllegalStateException("Mutation registered after phase was completed at: " +
- getStatementSourceReference());
- }
+ Preconditions.checkState(!phase.equals(finishedPhase),
+ "Mutation registered after phase was completed at: %s", getStatementSourceReference());
finishedPhase = finishedPhase.getPreviousPhase();
}
return false;
}
-
public void onDeclarationFinished(final Mutable<A, D, E> statement, final ModelProcessingPhase phase) {
switch (phase) {
- case SOURCE_PRE_LINKAGE:
- support.onPreLinkageDeclared(statement);
- break;
- case SOURCE_LINKAGE:
- support.onLinkageDeclared(statement);
- break;
- case STATEMENT_DEFINITION:
- support.onStatementDefinitionDeclared(statement);
- break;
- case FULL_DECLARATION:
- support.onFullDefinitionDeclared(statement);
- break;
- default:
- break;
+ case SOURCE_PRE_LINKAGE:
+ support.onPreLinkageDeclared(statement);
+ break;
+ case SOURCE_LINKAGE:
+ support.onLinkageDeclared(statement);
+ break;
+ case STATEMENT_DEFINITION:
+ support.onStatementDefinitionDeclared(statement);
+ break;
+ case FULL_DECLARATION:
+ support.onFullDefinitionDeclared(statement);
+ break;
+ default:
+ break;
}
}
@Override
int size() {
return countElements(elements);
- }
+ }
}
static int countElements(final Object[] elements) {
private final A argument;
/**
- * config statements are not all that common which means we are performing a recursive search towards the root
+ * Config statements are not all that common which means we are performing a recursive search towards the root
* every time {@link #isConfiguration()} is invoked. This is quite expensive because it causes a linear search
* for the (usually non-existent) config statement.
*
+ * <p>
* This field maintains a resolution cache, so once we have returned a result, we will keep on returning the same
* result without performing any lookups.
*/
public EffectiveStatement<QName, ActionStatement> createEffective(
final StmtContext<QName, ActionStatement, EffectiveStatement<QName, ActionStatement>> ctx) {
SourceException.throwIf(StmtContextUtils.hasAncestorOfType(ctx, ILLEGAL_PARENTS),
- ctx.getStatementSourceReference(), "Action %s is defined within a notification, rpc or another action",
- ctx.getStatementArgument());
+ ctx.getStatementSourceReference(),
+ "Action %s is defined within a notification, rpc or another action", ctx.getStatementArgument());
SourceException.throwIf(!StmtContextUtils.hasAncestorOfTypeWithChildOfType(ctx, YangStmtMapping.LIST,
YangStmtMapping.KEY), ctx.getStatementSourceReference(),
"Action %s is defined within a list that has no key statement", ctx.getStatementArgument());
}
@Override
- public void onStatementAdded(final Mutable<QName, AnydataStatement, EffectiveStatement<QName, AnydataStatement>> stmt) {
+ public void onStatementAdded(final Mutable<QName, AnydataStatement,
+ EffectiveStatement<QName, AnydataStatement>> stmt) {
stmt.getParentContext().addToNs(ChildSchemaNodes.class, stmt.getStatementArgument(), stmt);
}
public MandatoryStatement getMandatory() {
return firstDeclared(MandatoryStatement.class);
}
-
}
super(context);
}
- public static class Definition
- extends
- AbstractStatementSupport<ModifierKind, ModifierStatement, EffectiveStatement<ModifierKind, ModifierStatement>> {
+ public static class Definition extends AbstractStatementSupport<ModifierKind, ModifierStatement,
+ EffectiveStatement<ModifierKind, ModifierStatement>> {
public Definition() {
super(YangStmtMapping.MODIFIER);
@Override
public EffectiveStatement<ModifierKind, ModifierStatement> createEffective(
- final StmtContext<ModifierKind, ModifierStatement, EffectiveStatement<ModifierKind, ModifierStatement>> ctx) {
+ final StmtContext<ModifierKind, ModifierStatement,
+ EffectiveStatement<ModifierKind, ModifierStatement>> ctx) {
return new ModifierEffectiveStatementImpl(ctx);
}
@Override
public EffectiveStatement<QName, NotificationStatement> createEffective(
final StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
- SourceException
- .throwIf(StmtContextUtils.hasAncestorOfType(ctx, ILLEGAL_PARENTS), ctx.getStatementSourceReference(),
- "Notification %s is defined within an rpc, action, or another notification",
- ctx.getStatementArgument());
+ SourceException.throwIf(StmtContextUtils.hasAncestorOfType(ctx, ILLEGAL_PARENTS),
+ ctx.getStatementSourceReference(),
+ "Notification %s is defined within an rpc, action, or another notification",
+ ctx.getStatementArgument());
SourceException.throwIf(!StmtContextUtils.hasAncestorOfTypeWithChildOfType(ctx, YangStmtMapping.LIST,
- YangStmtMapping.KEY), ctx.getStatementSourceReference(),
- "Notification %s is defined within a list that has no key statement", ctx.getStatementArgument());
- SourceException.throwIf(StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.CASE), ctx.getStatementSourceReference(),
- "Notification %s is defined within a case statement", ctx.getStatementArgument());
+ YangStmtMapping.KEY), ctx.getStatementSourceReference(),
+ "Notification %s is defined within a list that has no key statement", ctx.getStatementArgument());
+ SourceException.throwIf(StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.CASE),
+ ctx.getStatementSourceReference(), "Notification %s is defined within a case statement",
+ ctx.getStatementArgument());
return new NotificationEffectiveStatementImpl(ctx);
}
*/
@Beta
public final class TypeStatementRfc7950Support extends TypeStatementImpl.Definition {
- private static final Map<String, StatementSupport<?, ?, ?>> ARGUMENT_SPECIFIC_SUPPORTS = ImmutableMap
- .<String, StatementSupport<?, ?, ?>> builder()
- .put(TypeUtils.LEAF_REF, new LeafrefSpecificationRfc7950Support())
- .put(TypeUtils.IDENTITY_REF, new IdentityrefSpecificationRfc7950Support()).build();
+ private static final Map<String, StatementSupport<?, ?, ?>> ARGUMENT_SPECIFIC_SUPPORTS =
+ ImmutableMap.<String, StatementSupport<?, ?, ?>>of(
+ TypeUtils.LEAF_REF, new LeafrefSpecificationRfc7950Support(),
+ TypeUtils.IDENTITY_REF, new IdentityrefSpecificationRfc7950Support());
@Override
public boolean hasArgumentSpecificSupports() {
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.OutputEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.TypeDefEffectiveStatementImpl;
-public class ActionEffectiveStatementImpl extends AbstractEffectiveSchemaNode<ActionStatement> implements ActionDefinition {
+public class ActionEffectiveStatementImpl extends AbstractEffectiveSchemaNode<ActionStatement>
+ implements ActionDefinition {
private final ContainerSchemaNode input;
private final ContainerSchemaNode output;
private final Set<TypeDefinition<?>> typeDefinitions;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementBase;
/**
- * Effective statement representation of 'yang-data' extension defined in https://tools.ietf.org/html/rfc8040#section-8
+ * Effective statement representation of 'yang-data' extension defined in
+ * <a href="https://tools.ietf.org/html/rfc8040#section-8">RFC 8040</a>.
*/
@Beta
public final class YangDataEffectiveStatement extends UnknownEffectiveStatementBase<String>
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.SupportedExtensionsMapping;
/**
- * Declared statement representation of 'yang-data' extension defined in https://tools.ietf.org/html/rfc8040#section-8
+ * Declared statement representation of 'yang-data' extension defined in
+ * <a href="https://tools.ietf.org/html/rfc8040#section-8">RFC 8040</a>.
*/
@Beta
public final class YangDataStatement extends AbstractDeclaredStatement<String> implements UnknownStatement<String> {
import org.opendaylight.yangtools.yang.parser.impl.util.YangModelDependencyInfo;
/**
- * Abstract Syntax Tree representation of a schema source. This representation
- * is internal to the YANG parser implementation, as it relies on ANTLR types.
+ * Abstract Syntax Tree representation of a schema source. This representation is internal to the YANG parser
+ * implementation, as it relies on ANTLR types.
*
- * Instances of this representation are used for caching purposes, as they
- * are a natural intermediate step in YANG text processing pipeline: the text
- * has been successfully parsed, so we know it is syntactically correct. It also
- * passes basic semantic validation and we were able to extract dependency
- * information.
+ * <p>
+ * Instances of this representation are used for caching purposes, as they are a natural intermediate step in YANG text
+ * processing pipeline: the text has been successfully parsed, so we know it is syntactically correct. It also passes
+ * basic semantic validation and we were able to extract dependency information.
*/
@Beta
public final class ASTSchemaSource implements SchemaSourceRepresentation {
return new ASTSchemaSource(id, semVerId, tree, depInfo, null);
}
- private static SourceIdentifier getSourceId(final YangModelDependencyInfo depInfo) {
- final String name = depInfo.getName();
- return depInfo.getFormattedRevision() == null ? RevisionSourceIdentifier.create(name)
- : RevisionSourceIdentifier.create(name, depInfo.getFormattedRevision());
- }
-
- private static SemVerSourceIdentifier getSemVerSourceId(final YangModelDependencyInfo depInfo) {
- return depInfo.getFormattedRevision() == null
- ? SemVerSourceIdentifier.create(depInfo.getName(),
- depInfo.getSemanticVersion().or(DEFAULT_SEMANTIC_VERSION))
- : SemVerSourceIdentifier.create(depInfo.getName(), depInfo.getFormattedRevision(),
- depInfo.getSemanticVersion().or(DEFAULT_SEMANTIC_VERSION));
- }
-
/**
* Create a new instance of AST representation for a abstract syntax tree,
* performing minimal semantic analysis to acquire dependency information.
/**
* Return the dependency information as extracted from the AST.
*
- * FIXME: this method should be extracted into a public interface in the
- * model.api.repo class, relying solely on model.api types.
- *
* @return Dependency information.
*/
+ // FIXME: this method should be extracted into a public interface in the model.api.repo class, relying solely
+ // on model.api types.
@Nonnull public YangModelDependencyInfo getDependencyInformation() {
return depInfo;
}
+
+ private static SourceIdentifier getSourceId(final YangModelDependencyInfo depInfo) {
+ final String name = depInfo.getName();
+ return depInfo.getFormattedRevision() == null ? RevisionSourceIdentifier.create(name)
+ : RevisionSourceIdentifier.create(name, depInfo.getFormattedRevision());
+ }
+
+ private static SemVerSourceIdentifier getSemVerSourceId(final YangModelDependencyInfo depInfo) {
+ return depInfo.getFormattedRevision() == null
+ ? SemVerSourceIdentifier.create(depInfo.getName(),
+ depInfo.getSemanticVersion().or(DEFAULT_SEMANTIC_VERSION))
+ : SemVerSourceIdentifier.create(depInfo.getName(), depInfo.getFormattedRevision(),
+ depInfo.getSemanticVersion().or(DEFAULT_SEMANTIC_VERSION));
+ }
}
@Deprecated
public final class ModuleDependencySort {
/**
- * It is not desirable to instance this class
+ * It is not desirable to instance this class.
*/
private ModuleDependencySort() {
}
public final class TextToASTTransformer extends SchemaSourceTransformer<YangTextSchemaSource, ASTSchemaSource> {
/**
+ * A text-to-AST Transformation.
+ *
* @deprecated Use {@link TextToASTTransformer#transformText(YangTextSchemaSource)} instead.
*/
@Deprecated
}
/**
+ * Singleton instance of {@link TextToASTTransformation}.
+ *
* @deprecated Use {@link TextToASTTransformer#transformText(YangTextSchemaSource)} instead.
*/
@Deprecated
final SchemaContext schemaContext = reactor.buildEffective(Arrays.asList(source));
assertNotNull(schemaContext);
- final Module testModule = schemaContext.findModuleByName( "foo",
+ final Module testModule = schemaContext.findModuleByName("foo",
SimpleDateFormatUtil.getRevisionFormat().parse("2016-09-20"));
assertNotNull(testModule);
assertFalse(ConstraintDefinitions.equals(constraints3, constraints4));
final String constraintsString = ConstraintDefinitions.toString(constraints4);
- assertEquals("EffectiveConstraintDefinitionImpl{whenCondition=foo = 'bar', mustConstraints=[bar != 'foo'], " +
- "mandatory=true, minElements=50, maxElements=100}", constraintsString);
+ assertEquals("EffectiveConstraintDefinitionImpl{whenCondition=foo = 'bar', mustConstraints=[bar != 'foo'], "
+ + "mandatory=true, minElements=50, maxElements=100}", constraintsString);
}
}
\ No newline at end of file