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.ImmutableMap;
13 import java.util.Collection;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
19 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.UsesNode;
21 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
22 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
24 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultArgument;
25 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.CopyableMixin;
26 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin.WithStatus;
27 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.WhenConditionMixin;
30 * Empty {@link UsesEffectiveStatement}, at its very simplest form. This is appropriate when all of these are true:
32 * <li>This statement takes effect in the same module as where it was declared, i.e. the arguments match</li>
33 * <li>It has no substatements</li>
37 * This provides minimum footprint, as we share the argument from the declared instance and just keep the flags and
38 * source grouping pointer.
40 class EmptyLocalUsesEffectiveStatement extends DefaultArgument<QName, UsesStatement>
41 implements UsesEffectiveStatement, UsesNode, CopyableMixin<QName, UsesStatement>,
42 WhenConditionMixin<QName, UsesStatement>, WithStatus<QName, UsesStatement> {
43 private final @NonNull GroupingDefinition sourceGrouping;
44 private final int flags;
46 EmptyLocalUsesEffectiveStatement(final UsesStatement declared, final GroupingDefinition sourceGrouping,
49 this.sourceGrouping = requireNonNull(sourceGrouping);
54 public final GroupingDefinition getSourceGrouping() {
55 return sourceGrouping;
59 public final int flags() {
64 public final UsesEffectiveStatement asEffectiveStatement() {
69 public final Collection<? extends AugmentationSchemaNode> getAugmentations() {
70 return filterEffectiveStatements(AugmentationSchemaNode.class);
74 public Map<Descendant, SchemaNode> getRefines() {
75 return ImmutableMap.of();