2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.sal.dom.broker.util;
11 import com.google.common.base.Preconditions;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Optional;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.common.Revision;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
22 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
25 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
26 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
27 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
28 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
29 import org.opendaylight.yangtools.yang.model.api.Status;
30 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
31 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.UsesNode;
35 * ProxySchema Context for SchemaContextProviders.
37 public class ProxySchemaContext implements SchemaContext {
39 private final SchemaContextProvider schemaProvider;
41 public ProxySchemaContext(final SchemaContextProvider schemaProvider) {
42 this.schemaProvider = schemaProvider;
45 private SchemaContext getCurrentSchema() {
46 Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s",
48 return schemaProvider.getSchemaContext();
52 public Set<DataSchemaNode> getDataDefinitions() {
53 return getCurrentSchema().getDataDefinitions();
57 public Set<Module> getModules() {
58 return getCurrentSchema().getModules();
62 public Set<NotificationDefinition> getNotifications() {
63 return getCurrentSchema().getNotifications();
67 public Set<RpcDefinition> getOperations() {
68 return getCurrentSchema().getOperations();
72 public Set<ExtensionDefinition> getExtensions() {
73 return getCurrentSchema().getExtensions();
77 public boolean isPresenceContainer() {
78 return getCurrentSchema().isPresenceContainer();
82 public Set<TypeDefinition<?>> getTypeDefinitions() {
83 return getCurrentSchema().getTypeDefinitions();
87 public Collection<DataSchemaNode> getChildNodes() {
88 return getCurrentSchema().getChildNodes();
92 public Set<GroupingDefinition> getGroupings() {
93 return getCurrentSchema().getGroupings();
97 public Optional<DataSchemaNode> findDataChildByName(final QName name) {
98 return getCurrentSchema().findDataChildByName(name);
102 public Set<UsesNode> getUses() {
103 return getCurrentSchema().getUses();
107 public Set<AugmentationSchemaNode> getAvailableAugmentations() {
108 return getCurrentSchema().getAvailableAugmentations();
112 public boolean isAugmenting() {
113 return getCurrentSchema().isAugmenting();
117 public boolean isAddedByUses() {
118 return getCurrentSchema().isAddedByUses();
122 public boolean isConfiguration() {
123 return getCurrentSchema().isConfiguration();
127 public QName getQName() {
128 return getCurrentSchema().getQName();
132 public SchemaPath getPath() {
133 return getCurrentSchema().getPath();
137 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
138 return getCurrentSchema().getUnknownSchemaNodes();
142 public Optional<String> getDescription() {
143 return getCurrentSchema().getDescription();
147 public Optional<String> getReference() {
148 return getCurrentSchema().getReference();
152 public Status getStatus() {
153 return getCurrentSchema().getStatus();
157 public Optional<Module> findModule(final String name, final Optional<Revision> revision) {
158 return getCurrentSchema().findModule(name, revision);
162 public Optional<Module> findModule(final QNameModule qnameModule) {
163 return getCurrentSchema().findModule(qnameModule);