+ return findNodeInModule(module.get(), path);
+ }
+
+ /**
+ * Returns NotificationDefinition from Schema Context.
+ *
+ * @param schema SchemaContext in which lookup should be performed.
+ * @param path Schema Path of notification
+ * @return Notification schema or null, if notification is not present in schema context.
+ */
+ @Beta
+ @Nullable
+ public static NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema,
+ @Nonnull final SchemaPath path) {
+ Preconditions.checkNotNull(schema, "Schema context must not be null.");
+ Preconditions.checkNotNull(path, "Schema path must not be null.");
+ for (final NotificationDefinition potential : schema.getNotifications()) {
+ if (path.equals(potential.getPath())) {
+ return potential;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns RPC Input or Output Data container from RPC definition.
+ *
+ * @param schema SchemaContext in which lookup should be performed.
+ * @param path Schema path of RPC input/output data container
+ * @return Notification schema or null, if notification is not present in schema context.
+ */
+ @Beta
+ @Nullable
+ public static ContainerSchemaNode getRpcDataSchema(@Nonnull final SchemaContext schema,
+ @Nonnull final SchemaPath path) {
+ Preconditions.checkNotNull(schema, "Schema context must not be null.");
+ Preconditions.checkNotNull(path, "Schema path must not be null.");
+ final Iterator<QName> it = path.getPathFromRoot().iterator();
+ Preconditions.checkArgument(it.hasNext(), "Rpc must have QName.");
+ final QName rpcName = it.next();
+ Preconditions.checkArgument(it.hasNext(), "input or output must be part of path.");
+ final QName inOrOut = it.next();
+ for (final RpcDefinition potential : schema.getOperations()) {
+ if (rpcName.equals(potential.getQName())) {
+ return SchemaNodeUtils.getRpcDataSchema(potential, inOrOut);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Extract the identifiers of all modules and submodules which were used to create a particular SchemaContext.
+ *
+ * @param context SchemaContext to be examined
+ * @return Set of ModuleIdentifiers.
+ */
+ public static Set<SourceIdentifier> getConstituentModuleIdentifiers(final SchemaContext context) {
+ final Set<SourceIdentifier> ret = new HashSet<>();
+
+ for (Module module : context.getModules()) {
+ ret.add(moduleToIdentifier(module));
+
+ for (Module submodule : module.getSubmodules()) {
+ ret.add(moduleToIdentifier(submodule));
+ }
+ }
+
+ return ret;