- NotificationCodecContext<?> createNotificationDataContext(final Class<?> notificationType) {
- checkArgument(Notification.class.isAssignableFrom(notificationType));
- checkArgument(notificationType.isInterface(), "Supplied class must be interface.");
- final QName qname = BindingReflections.findQName(notificationType);
- final NotificationDefinition schema = getSchema().findNotification(qname).orElseThrow(
- () -> new IllegalArgumentException("Supplied " + notificationType + " is not valid notification"));
- return new NotificationCodecContext<>(notificationType, schema, factory());
+ /**
+ * 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.
+ */
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
+ private static @Nullable ContainerLike getRpcDataSchema(final @NonNull EffectiveModelContext schema,
+ final @NonNull Absolute path) {
+ requireNonNull(schema, "Schema context must not be null.");
+ requireNonNull(path, "Schema path must not be null.");
+ final Iterator<QName> it = path.getNodeIdentifiers().iterator();
+ checkArgument(it.hasNext(), "Rpc must have QName.");
+ final QName rpcName = it.next();
+ 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 getRpcDataSchema(potential, inOrOut);
+ }
+ }
+ return null;