/**
* Effective model statement which should be used to derive application behaviour.
*
- * @param <A> Argument type ({@link Void} if statement does not have argument.)
- * @param <D> Class representing declared version of this statement.
+ * @param <A>
+ * Argument type ({@link Void} if statement does not have argument.)
+ * @param <S>
+ * Class representing declared version of this statement.
*/
-public interface EffectiveStatement<A, D extends DeclaredStatement<A>> extends ModelStatement<A> {
+public interface EffectiveStatement<A, S extends DeclaredStatement<A>> extends ModelStatement<A> {
+
/**
* Returns statement, which was explicit declaration of this effective
* statement.
* statement or null if statement was inferred from context.
*/
@Nullable
- D getDeclared();
+ S getDeclared();
/**
* Returns value associated with supplied identifier.
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface ActionEffectiveStatement extends SchemaTreeEffectiveStatement<ActionStatement>,
- SchemaTreeAwareEffectiveStatement<QName, ActionStatement> {
+public interface ActionEffectiveStatement extends EffectiveStatement<QName, ActionStatement> {
}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface AnydataEffectiveStatement extends SchemaTreeEffectiveStatement<AnydataStatement> {
+public interface AnydataEffectiveStatement extends EffectiveStatement<QName, AnydataStatement> {
}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface AnyxmlEffectiveStatement extends SchemaTreeEffectiveStatement<AnyxmlStatement> {
+public interface AnyxmlEffectiveStatement extends EffectiveStatement<QName, AnyxmlStatement> {
}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.common.QName;
@Beta
-public interface CaseEffectiveStatement extends SchemaTreeEffectiveStatement<CaseStatement>,
- SchemaTreeAwareEffectiveStatement<QName, CaseStatement> {
+public interface CaseEffectiveStatement extends NamespacedEffectiveStatement<CaseStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface ChoiceEffectiveStatement extends SchemaTreeEffectiveStatement<ChoiceStatement>,
- SchemaTreeAwareEffectiveStatement<QName, ChoiceStatement> {
+public interface ChoiceEffectiveStatement extends EffectiveStatement<QName, ChoiceStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface ContainerEffectiveStatement extends SchemaTreeEffectiveStatement<ContainerStatement>,
- SchemaTreeAwareEffectiveStatement<QName, ContainerStatement> {
+public interface ContainerEffectiveStatement extends EffectiveStatement<QName, ContainerStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface InputEffectiveStatement extends SchemaTreeEffectiveStatement<InputStatement>,
- SchemaTreeAwareEffectiveStatement<QName, InputStatement> {
+public interface InputEffectiveStatement extends EffectiveStatement<QName, InputStatement> {
}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface LeafEffectiveStatement extends SchemaTreeEffectiveStatement<LeafStatement> {
+public interface LeafEffectiveStatement extends EffectiveStatement<QName, LeafStatement> {
}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface LeafListEffectiveStatement extends SchemaTreeEffectiveStatement<LeafListStatement> {
+public interface LeafListEffectiveStatement extends EffectiveStatement<QName, LeafListStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface ListEffectiveStatement extends SchemaTreeEffectiveStatement<ListStatement>,
- SchemaTreeAwareEffectiveStatement<QName, ListStatement> {
+public interface ListEffectiveStatement extends EffectiveStatement<QName, ListStatement> {
}
import com.google.common.annotations.Beta;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
/**
// an ordinary String. We really want this to be a QName, so that we do not need the localQNameModule
// bit, but that may be problematic with ModuleStatement, which is getting created before we even know
// the namespace :( A type capture of the string may just be sufficient.
-public interface ModuleEffectiveStatement extends SchemaTreeAwareEffectiveStatement<String, ModuleStatement> {
+public interface ModuleEffectiveStatement extends EffectiveStatement<String, ModuleStatement> {
/**
* Namespace mapping all known prefixes in a module to their modules. Note this namespace includes the module
* in which it is instantiated.
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface NotificationEffectiveStatement extends SchemaTreeEffectiveStatement<NotificationStatement>,
- SchemaTreeAwareEffectiveStatement<QName, NotificationStatement> {
+public interface NotificationEffectiveStatement extends EffectiveStatement<QName, NotificationStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface OutputEffectiveStatement extends SchemaTreeEffectiveStatement<OutputStatement>,
- SchemaTreeAwareEffectiveStatement<QName, OutputStatement> {
+public interface OutputEffectiveStatement extends EffectiveStatement<QName, OutputStatement> {
}
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Beta
-public interface RpcEffectiveStatement extends SchemaTreeEffectiveStatement<RpcStatement>,
- SchemaTreeAwareEffectiveStatement<QName, RpcStatement> {
+public interface RpcEffectiveStatement extends EffectiveStatement<QName, RpcStatement> {
}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.model.api.stmt;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-
-/**
- * Interface implemented by all {@link EffectiveStatement}s which can contain a {@code schema tree} child. This tree
- * can be walked using {@link SchemaNodeIdentifier}, looking up each component of
- * {@link SchemaNodeIdentifier#getPathFromRoot()} using {@link #findSchemaTreeNode(QName)}.
- *
- * @param <A> Argument type
- * @param <D> Class representing declared version of this statement.
- * @author Robert Varga
- */
-@Beta
-public interface SchemaTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
- /**
- * Namespace of {@code schema node}s defined within this node.
- *
- * @param <T> Child statement type
- * @author Robert Varga
- */
- @NonNullByDefault
- abstract class Namespace<T extends SchemaTreeEffectiveStatement<?>> extends EffectiveStatementNamespace<T> {
- private Namespace() {
- // Should never be instantiated
- }
- }
-
- /**
- * Find a {@code schema tree} child {@link SchemaTreeEffectiveStatement}, as identified by its QName argument.
- *
- * @param qname Child identifier
- * @return Schema tree child, or empty
- * @throws NullPointerException if {@code qname} is null
- */
- // FIXME: make sure this namespace is populated
- default <E extends SchemaTreeEffectiveStatement<?>> @NonNull Optional<E> findSchemaTreeNode(
- final @NonNull QName qname) {
- return Optional.ofNullable(get(Namespace.class, requireNonNull(qname)));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.model.api.stmt;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-
-/**
- * Common interface grouping all {@link EffectiveStatement}s which are accessible via
- * {@link SchemaTreeAwareEffectiveStatement.Namespace}. This such statement corresponds to a {@code schema node}.
- *
- * <p>
- * This interface could be named {@code SchemaNodeEffectiveStatement}, but that could induce a notion that it has
- * something to do with {@link SchemaNode} -- which it has not. SchemaNode semantics are wrong in may aspects
- * and while implementations of this interface may also implement SchemaNode, the semantics of this interface should
- * always be preferred and SchemaNode is to be treated as deprecated whenever possible.
- *
- * @param <D> Declared statement type
- * @author Robert Varga
- */
-@Beta
-public interface SchemaTreeEffectiveStatement<D extends DeclaredStatement<QName>>
- extends NamespacedEffectiveStatement<D> {
-
-}
import org.opendaylight.yangtools.yang.parser.spi.source.AugmentToChoiceNamespace;
public abstract class AbstractEffectiveDocumentedDataNodeContainer<A, D extends DeclaredStatement<A>>
- extends AbstractSchemaEffectiveDocumentedNode<A, D> implements DataNodeContainer {
+ extends AbstractEffectiveDocumentedNode<A, D> implements DataNodeContainer {
private final Map<QName, DataSchemaNode> childNodes;
private final Set<GroupingDefinition> groupings;
@Beta
public abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> extends
- AbstractSchemaEffectiveDocumentedNode<String, D> implements Module, MutableStatement {
+ AbstractEffectiveDocumentedNode<String, D> implements Module, MutableStatement {
private final String name;
private final String prefix;
private final YangVersion yangVersion;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
public abstract class AbstractEffectiveSchemaNode<D extends DeclaredStatement<QName>> extends
- AbstractSchemaEffectiveDocumentedNode<QName, D> implements SchemaNode {
+ AbstractEffectiveDocumentedNode<QName, D> implements SchemaNode {
private final SchemaPath path;
private final List<UnknownSchemaNode> unknownNodes;
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.parser.rfc7950.stmt;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Optional;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeAwareEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
-
-/**
- * An {@link AbstractEffectiveDocumentedNode} which can optionally support {@link SchemaTreeAwareEffectiveStatement}.
- *
- * @param <A> Argument type ({@link Void} if statement does not have argument.)
- * @param <D> Class representing declared version of this statement.
- * @author Robert Varga
- */
-@Beta
-public abstract class AbstractSchemaEffectiveDocumentedNode<A, D extends DeclaredStatement<A>>
- extends AbstractEffectiveDocumentedNode<A, D> {
-
- private final Map<QName, SchemaTreeEffectiveStatement<?>> schemaTreeNamespace;
-
- protected AbstractSchemaEffectiveDocumentedNode(final StmtContext<A, D, ?> ctx) {
- super(ctx);
-
- if (this instanceof SchemaTreeAwareEffectiveStatement) {
- final StatementSourceReference ref = ctx.getStatementSourceReference();
- final Map<QName, SchemaTreeEffectiveStatement<?>> schemaChildren = new LinkedHashMap<>();
- streamEffectiveSubstatements(SchemaTreeEffectiveStatement.class).forEach(child -> {
- putChild(schemaChildren, child, ref, "schema");
- });
- schemaTreeNamespace = ImmutableMap.copyOf(schemaChildren);
- } else {
- schemaTreeNamespace = ImmutableMap.of();
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected <K, V, N extends IdentifierNamespace<K, V>> Optional<? extends Map<K, V>> getNamespaceContents(
- final Class<N> namespace) {
- if (this instanceof SchemaTreeAwareEffectiveStatement
- && SchemaTreeAwareEffectiveStatement.Namespace.class.equals(namespace)) {
- return Optional.of((Map<K, V>) schemaTreeNamespace);
- }
- return super.getNamespaceContents(namespace);
- }
-
- private static <T extends SchemaTreeEffectiveStatement<?>> void putChild(final Map<QName, T> map,
- final T child, final StatementSourceReference ref, final String tree) {
- final QName id = child.getIdentifier();
- final T prev = map.putIfAbsent(id, child);
- SourceException.throwIf(prev != null, ref,
- "Cannot add %s tree child with name %s, a conflicting child already exists", tree, id);
- }
-}
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
public abstract class UnknownEffectiveStatementBase<A, D extends UnknownStatement<A>>
- extends AbstractSchemaEffectiveDocumentedNode<A, D> implements UnknownSchemaNode {
+ extends AbstractEffectiveDocumentedNode<A, D> implements UnknownSchemaNode {
private final boolean addedByUses;
private final boolean addedByAugmentation;