2 * Copyright (c) 2013 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.controller.yang.parser.impl;
11 import java.util.Date;
12 import java.util.HashSet;
15 import org.opendaylight.controller.yang.model.api.DataSchemaNode;
16 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
17 import org.opendaylight.controller.yang.model.api.Module;
18 import org.opendaylight.controller.yang.model.api.NotificationDefinition;
19 import org.opendaylight.controller.yang.model.api.RpcDefinition;
20 import org.opendaylight.controller.yang.model.api.SchemaContext;
22 final class SchemaContextImpl implements SchemaContext {
23 private final Set<Module> modules;
25 SchemaContextImpl(final Set<Module> modules) {
26 this.modules = modules;
30 public Set<DataSchemaNode> getDataDefinitions() {
31 final Set<DataSchemaNode> dataDefs = new HashSet<DataSchemaNode>();
32 for (Module m : modules) {
33 dataDefs.addAll(m.getChildNodes());
39 public Set<Module> getModules() {
44 public Set<NotificationDefinition> getNotifications() {
45 final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();
46 for (Module m : modules) {
47 notifications.addAll(m.getNotifications());
53 public Set<RpcDefinition> getOperations() {
54 final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();
55 for (Module m : modules) {
56 rpcs.addAll(m.getRpcs());
62 public Set<ExtensionDefinition> getExtensions() {
63 final Set<ExtensionDefinition> extensions = new HashSet<ExtensionDefinition>();
64 for (Module m : modules) {
65 extensions.addAll(m.getExtensionSchemaNodes());
71 public Module findModuleByName(final String name, final Date revision) {
73 for (final Module module : modules) {
74 if (revision == null) {
75 if (module.getName().equals(name)) {
78 } else if (module.getName().equals(name) && module.getRevision().equals(revision)) {
87 public Module findModuleByNamespace(final URI namespace) {
88 if (namespace != null) {
89 for (final Module module : modules) {
90 if (module.getNamespace().equals(namespace)) {