2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import com.google.common.collect.ImmutableMap;
14 import java.util.Collection;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
20 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.UsesNode;
22 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
24 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
25 import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
26 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultWithArgument;
27 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.CopyableMixin;
28 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin.WithStatus;
29 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.WhenConditionMixin;
32 * A simple case of a copied statement. The key difference here is that the argument does not match the declared
33 * argument -- i.e. the effective instance is in a different module. This also means that there is some history
34 * copy history attached.
37 * Since we have to keep the argument already, we perform a different field cut than in the local case and handle
38 * also substatements here. We do not handle further refines, though, as that requires yet another field, further
39 * growing instance size. That case is handled by {@link FullCopiedUsesEffectiveStatement}.
41 class SimpleCopiedUsesEffectiveStatement extends DefaultWithArgument.WithSubstatements<QName, UsesStatement>
42 implements UsesEffectiveStatement, UsesNode, CopyableMixin<QName, UsesStatement>,
43 WhenConditionMixin<QName, UsesStatement>, WithStatus<QName, UsesStatement> {
44 private final @NonNull GroupingDefinition sourceGrouping;
45 private final int flags;
47 SimpleCopiedUsesEffectiveStatement(final UsesStatement declared, final QName argument,
48 final GroupingDefinition sourceGrouping, final int flags,
49 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
50 super(declared, argument, substatements);
51 this.sourceGrouping = requireNonNull(sourceGrouping);
55 SimpleCopiedUsesEffectiveStatement(final UsesStatement declared, final QName argument,
56 final GroupingDefinition sourceGrouping, final int flags) {
57 this(declared, argument, sourceGrouping, flags, ImmutableList.of());
61 public final GroupingDefinition getSourceGrouping() {
62 return sourceGrouping;
66 public final int flags() {
71 public final Collection<? extends AugmentationSchemaNode> getAugmentations() {
72 return filterEffectiveStatements(AugmentationSchemaNode.class);
76 public final UsesEffectiveStatement asEffectiveStatement() {
81 public Map<Descendant, SchemaNode> getRefines() {
82 return ImmutableMap.of();