These two namespaces should not be generic, but rather specialized
to the corresponding wildcard statement. This fixes a number of
usability issues where type inference would not work correctly.
Change-Id: I0b4a2461df58265ae2db795c0c81e2b4e5972e41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.Optional;
import java.util.function.BiFunction;
import org.eclipse.jdt.annotation.NonNull;
import java.util.Optional;
import java.util.function.BiFunction;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.util.codec.CodecCache;
import org.opendaylight.yangtools.yang.data.util.codec.LazyCodecCache;
import org.opendaylight.yangtools.yang.data.util.codec.NoopCodecCache;
import org.opendaylight.yangtools.yang.data.util.codec.CodecCache;
import org.opendaylight.yangtools.yang.data.util.codec.LazyCodecCache;
import org.opendaylight.yangtools.yang.data.util.codec.NoopCodecCache;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeAwareEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeAwareEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeAwareEffectiveStatement.Namespace;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
private static int codecsForChildren(final JSONCodecFactory lazy, final SchemaInferenceStack stack,
final DataTreeAwareEffectiveStatement<?, ?> parent) {
int ret = 0;
private static int codecsForChildren(final JSONCodecFactory lazy, final SchemaInferenceStack stack,
final DataTreeAwareEffectiveStatement<?, ?> parent) {
int ret = 0;
- final Map<QName, DataTreeEffectiveStatement<?>> dataTree =
- parent.getAll(DataTreeAwareEffectiveStatement.Namespace.class);
- for (DataTreeEffectiveStatement<?> child : dataTree.values()) {
+ for (var entry : parent.getAll(Namespace.class).entrySet()) {
+ final var child = entry.getValue();
if (child instanceof DataTreeAwareEffectiveStatement) {
if (child instanceof DataTreeAwareEffectiveStatement) {
- stack.enterDataTree(child.argument());
+ stack.enterDataTree(entry.getKey());
ret += codecsForChildren(lazy, stack, (DataTreeAwareEffectiveStatement<?, ?>) child);
stack.exit();
} else if (child instanceof TypedDataSchemaNode) {
ret += codecsForChildren(lazy, stack, (DataTreeAwareEffectiveStatement<?, ?>) child);
stack.exit();
} else if (child instanceof TypedDataSchemaNode) {
*
* <p>
* This corresponds to the {@code data tree} view of a YANG-defined data.
*
* <p>
* This corresponds to the {@code data tree} view of a YANG-defined data.
- *
- * @param <T> Child statement type
- abstract class Namespace<T extends DataTreeEffectiveStatement<?>> extends EffectiveStatementNamespace<T> {
+ abstract class Namespace extends EffectiveStatementNamespace<DataTreeEffectiveStatement<?>> {
private Namespace() {
// Should never be instantiated
}
private Namespace() {
// Should never be instantiated
}
*
* @param <A> Argument type
* @param <D> Class representing declared version of this statement.
*
* @param <A> Argument type
* @param <D> Class representing declared version of this statement.
*/
@Beta
public interface SchemaTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
/**
* Namespace of {@code schema node}s defined within this node.
*/
@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
- abstract class Namespace<T extends SchemaTreeEffectiveStatement<?>> extends EffectiveStatementNamespace<T> {
+ abstract class Namespace extends EffectiveStatementNamespace<SchemaTreeEffectiveStatement<?>> {
private Namespace() {
// Should never be instantiated
}
private Namespace() {
// Should never be instantiated
}
// 'action' identifier must never collide with another element, hence if we look it up and it ends up being
// an ActionDefinition, we have found a match.
return get(Namespace.class, qname)
// 'action' identifier must never collide with another element, hence if we look it up and it ends up being
// an ActionDefinition, we have found a match.
return get(Namespace.class, qname)
- .flatMap(child -> child instanceof ActionDefinition ? Optional.of(child) : Optional.empty());
+ .flatMap(child -> child instanceof ActionDefinition ? Optional.of((ActionDefinition) child)
+ : Optional.empty());
// 'notification' identifier must never collide with another element, hence if we look it up and it ends up
// being an NotificationDefinition, we have found a match.
return get(Namespace.class, qname)
// 'notification' identifier must never collide with another element, hence if we look it up and it ends up
// being an NotificationDefinition, we have found a match.
return get(Namespace.class, qname)
- .flatMap(child -> child instanceof NotificationDefinition ? Optional.of(child) : Optional.empty());
+ .flatMap(child -> child instanceof NotificationDefinition ? Optional.of((NotificationDefinition) child)
+ : Optional.empty());