2 * Copyright (c) 2016 ZTE, 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.data.util;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import com.google.common.collect.ImmutableSet;
14 import java.util.Collection;
15 import java.util.Optional;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.ContainerLike;
21 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
23 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
24 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
25 import org.opendaylight.yangtools.yang.model.api.NotificationNodeContainer;
26 import org.opendaylight.yangtools.yang.model.api.OperationDefinition;
27 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
28 import org.opendaylight.yangtools.yang.model.api.Status;
29 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
30 import org.opendaylight.yangtools.yang.model.api.UsesNode;
31 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
34 * Utility class for taking notification or rpc as ContainerSchemaNode.
36 * @author <a href="mailto:geng.xingyuan@zte.com.cn">Geng Xingyuan</a>
37 * @deprecated This class is deprecated for removal. Use {@link NotificationDefinition#toContainerLike()} and
38 * {@link OperationDefinition#toContainerLike()} to can similar service. Note that the former differs from
39 * {@link #forNotification(NotificationDefinition)} in that it does not report the source notification from
40 * {@link NotificationNodeContainer#getNotifications()} -- i.e. it does not contain itself.
42 @Deprecated(since = "11.0.0", forRemoval = true)
43 public final class ContainerSchemaNodes {
44 private ContainerSchemaNodes() {
48 public static @NonNull ContainerLike forNotification(final NotificationDefinition notification) {
49 return new NotificationContainerSchemaNode(notification);
52 public static @NonNull ContainerLike forRPC(final RpcDefinition rpc) {
53 return rpc.toContainerLike();
56 private static final class NotificationContainerSchemaNode implements ContainerLike {
57 final @NonNull NotificationDefinition schemaNode;
59 NotificationContainerSchemaNode(final NotificationDefinition schemaNode) {
60 this.schemaNode = requireNonNull(schemaNode);
64 public Optional<String> getDescription() {
65 return schemaNode.getDescription();
69 public Optional<String> getReference() {
70 return schemaNode.getReference();
74 public Status getStatus() {
75 return schemaNode.getStatus();
79 public QName getQName() {
80 return schemaNode.getQName();
85 public boolean isAugmenting() {
90 @Deprecated(forRemoval = true)
91 public boolean isAddedByUses() {
96 public Optional<Boolean> effectiveConfig() {
97 return Optional.empty();
101 public Collection<? extends ActionDefinition> getActions() {
102 return ImmutableSet.of();
106 public Collection<? extends UsesNode> getUses() {
107 return ImmutableSet.of();
111 public Collection<? extends @NonNull MustDefinition> getMustConstraints() {
112 return ImmutableList.of();
116 public Optional<? extends QualifiedBound> getWhenCondition() {
117 return Optional.empty();
121 public Collection<? extends NotificationDefinition> getNotifications() {
122 return ImmutableSet.of(schemaNode);
126 public Collection<? extends AugmentationSchemaNode> getAvailableAugmentations() {
127 return schemaNode.getAvailableAugmentations();
131 public Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
132 return schemaNode.getTypeDefinitions();
136 public Collection<? extends DataSchemaNode> getChildNodes() {
137 return schemaNode.getChildNodes();
141 public Collection<? extends GroupingDefinition> getGroupings() {
142 return schemaNode.getGroupings();
146 public DataSchemaNode dataChildByName(final QName name) {
147 return schemaNode.dataChildByName(name);