Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / util / ProxySchemaContext.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.sal.dom.broker.util;
10
11 import com.google.common.base.Preconditions;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Optional;
15 import java.util.Set;
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;
33
34 /**
35  * ProxySchema Context for SchemaContextProviders.
36  */
37 public class ProxySchemaContext implements SchemaContext {
38
39     private final SchemaContextProvider schemaProvider;
40
41     public ProxySchemaContext(final SchemaContextProvider schemaProvider) {
42         this.schemaProvider = schemaProvider;
43     }
44
45     private SchemaContext getCurrentSchema() {
46         Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s",
47                                  schemaProvider);
48         return schemaProvider.getSchemaContext();
49     }
50
51     @Override
52     public Set<DataSchemaNode> getDataDefinitions() {
53         return getCurrentSchema().getDataDefinitions();
54     }
55
56     @Override
57     public Set<Module> getModules() {
58         return getCurrentSchema().getModules();
59     }
60
61     @Override
62     public Set<NotificationDefinition> getNotifications() {
63         return getCurrentSchema().getNotifications();
64     }
65
66     @Override
67     public Set<RpcDefinition> getOperations() {
68         return getCurrentSchema().getOperations();
69     }
70
71     @Override
72     public Set<ExtensionDefinition> getExtensions() {
73         return getCurrentSchema().getExtensions();
74     }
75
76     @Override
77     public boolean isPresenceContainer() {
78         return getCurrentSchema().isPresenceContainer();
79     }
80
81     @Override
82     public Set<TypeDefinition<?>> getTypeDefinitions() {
83         return getCurrentSchema().getTypeDefinitions();
84     }
85
86     @Override
87     public Collection<DataSchemaNode> getChildNodes() {
88         return getCurrentSchema().getChildNodes();
89     }
90
91     @Override
92     public Set<GroupingDefinition> getGroupings() {
93         return getCurrentSchema().getGroupings();
94     }
95
96     @Override
97     public Optional<DataSchemaNode> findDataChildByName(final QName name) {
98         return getCurrentSchema().findDataChildByName(name);
99     }
100
101     @Override
102     public Set<UsesNode> getUses() {
103         return getCurrentSchema().getUses();
104     }
105
106     @Override
107     public Set<AugmentationSchemaNode> getAvailableAugmentations() {
108         return getCurrentSchema().getAvailableAugmentations();
109     }
110
111     @Override
112     public boolean isAugmenting() {
113         return getCurrentSchema().isAugmenting();
114     }
115
116     @Override
117     public boolean isAddedByUses() {
118         return getCurrentSchema().isAddedByUses();
119     }
120
121     @Override
122     public boolean isConfiguration() {
123         return getCurrentSchema().isConfiguration();
124     }
125
126     @Override
127     public QName getQName() {
128         return getCurrentSchema().getQName();
129     }
130
131     @Override
132     public SchemaPath getPath() {
133         return getCurrentSchema().getPath();
134     }
135
136     @Override
137     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
138         return getCurrentSchema().getUnknownSchemaNodes();
139     }
140
141     @Override
142     public Optional<String> getDescription() {
143         return getCurrentSchema().getDescription();
144     }
145
146     @Override
147     public Optional<String> getReference() {
148         return getCurrentSchema().getReference();
149     }
150
151     @Override
152     public Status getStatus() {
153         return getCurrentSchema().getStatus();
154     }
155
156     @Override
157     public Optional<Module> findModule(final String name, final Optional<Revision> revision) {
158         return getCurrentSchema().findModule(name, revision);
159     }
160
161     @Override
162     public Optional<Module> findModule(final QNameModule qnameModule) {
163         return getCurrentSchema().findModule(qnameModule);
164     }
165 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.