2 * Copyright (c) 2015 Cisco Systems, Inc. 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.model.spi.meta;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.Collections2;
14 import com.google.common.collect.ImmutableList;
15 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.CopyableNode;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
24 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin;
27 * A declared {@link AbstractDeclaredEffectiveStatement} with {@link UnknownSchemaNode}.
30 public abstract class AbstractEffectiveUnknownSchmemaNode<A, D extends UnknownStatement<A>>
31 extends AbstractDeclaredEffectiveStatement<A, D>
32 implements DocumentedNodeMixin<A, D>, UnknownSchemaNode {
33 private final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
34 private final @NonNull D declared;
35 private final @NonNull A argument;
36 @Deprecated(since = "7.0.9")
37 private final boolean addedByUses;
38 private final boolean augmenting;
40 protected AbstractEffectiveUnknownSchmemaNode(final @NonNull D declared, final A argument,
41 final CopyableNode history,
42 final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
43 this.argument = requireNonNull(argument);
44 this.declared = requireNonNull(declared);
45 this.substatements = requireNonNull(substatements);
46 this.augmenting = history.isAugmenting();
47 this.addedByUses = history.isAddedByUses();
51 public final A argument() {
56 public final @NonNull D getDeclared() {
61 public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
66 public final QName getNodeType() {
67 return statementDefinition().getStatementName();
71 public final String getNodeParameter() {
72 final String rawArgument = getDeclared().rawArgument();
73 return rawArgument == null ? "" : rawArgument;
78 public final boolean isAddedByUses() {
84 public final boolean isAugmenting() {
89 public String toString() {
90 final QName type = getNodeType();
91 return type.getNamespace() + ":" + type.getLocalName() + " " + getNodeParameter();
94 @SuppressWarnings("unchecked")
95 public final <T> Collection<T> allSubstatementsOfType(final Class<T> type) {
96 return Collection.class.cast(Collections2.filter(effectiveSubstatements(), type::isInstance));
100 public final Status getStatus() {
101 return findFirstEffectiveSubstatementArgument(StatusEffectiveStatement.class).orElse(Status.CURRENT);