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.Optional;
12 import com.google.common.base.Preconditions;
14 import java.util.Collection;
15 import java.util.Date;
16 import java.util.List;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
20 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
21 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
23 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
24 import org.opendaylight.yangtools.yang.model.api.Module;
25 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
26 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
27 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
28 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
29 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
30 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
31 import org.opendaylight.yangtools.yang.model.api.Status;
32 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
33 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
34 import org.opendaylight.yangtools.yang.model.api.UsesNode;
37 * ProxySchema Context for SchemaContextProviders.
39 public class ProxySchemaContext implements SchemaContext {
41 private final SchemaContextProvider schemaProvider;
43 public ProxySchemaContext(final SchemaContextProvider schemaProvider) {
44 this.schemaProvider = schemaProvider;
47 private SchemaContext getCurrentSchema() {
48 Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s",
50 return schemaProvider.getSchemaContext();
54 public Set<DataSchemaNode> getDataDefinitions() {
55 return getCurrentSchema().getDataDefinitions();
59 public Set<Module> getModules() {
60 return getCurrentSchema().getModules();
64 public Set<NotificationDefinition> getNotifications() {
65 return getCurrentSchema().getNotifications();
69 public Set<RpcDefinition> getOperations() {
70 return getCurrentSchema().getOperations();
74 public Set<ExtensionDefinition> getExtensions() {
75 return getCurrentSchema().getExtensions();
79 public Module findModuleByName(final String string, final Date date) {
80 return getCurrentSchema().findModuleByName(string, date);
84 public Set<Module> findModuleByNamespace(final URI uri) {
85 return getCurrentSchema().findModuleByNamespace(uri);
89 public Module findModuleByNamespaceAndRevision(final URI uri, final Date date) {
90 return getCurrentSchema().findModuleByNamespaceAndRevision(uri, date);
94 public Optional<String> getModuleSource(final ModuleIdentifier moduleIdentifier) {
95 return getCurrentSchema().getModuleSource(moduleIdentifier);
99 public Set<ModuleIdentifier> getAllModuleIdentifiers() {
100 return getCurrentSchema().getAllModuleIdentifiers();
104 public boolean isPresenceContainer() {
105 return getCurrentSchema().isPresenceContainer();
109 public Set<TypeDefinition<?>> getTypeDefinitions() {
110 return getCurrentSchema().getTypeDefinitions();
114 public Collection<DataSchemaNode> getChildNodes() {
115 return getCurrentSchema().getChildNodes();
119 public Set<GroupingDefinition> getGroupings() {
120 return getCurrentSchema().getGroupings();
124 public DataSchemaNode getDataChildByName(final QName name) {
125 return getCurrentSchema().getDataChildByName(name);
129 public Set<UsesNode> getUses() {
130 return getCurrentSchema().getUses();
134 public Set<AugmentationSchema> getAvailableAugmentations() {
135 return getCurrentSchema().getAvailableAugmentations();
139 public boolean isAugmenting() {
140 return getCurrentSchema().isAugmenting();
144 public boolean isAddedByUses() {
145 return getCurrentSchema().isAddedByUses();
149 public boolean isConfiguration() {
150 return getCurrentSchema().isConfiguration();
154 public ConstraintDefinition getConstraints() {
155 return getCurrentSchema().getConstraints();
159 public QName getQName() {
160 return getCurrentSchema().getQName();
164 public SchemaPath getPath() {
165 return getCurrentSchema().getPath();
169 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
170 return getCurrentSchema().getUnknownSchemaNodes();
174 public String getDescription() {
175 return getCurrentSchema().getDescription();
179 public String getReference() {
180 return getCurrentSchema().getReference();
184 public Status getStatus() {
185 return getCurrentSchema().getStatus();