Hello,
Thank you for your answer, but this doesn't solve my point at all.
Taking the exemple from the documentation, I'll try to highlight the enhancement that should be done, using comment:
public class UserPresenceListener implements NotificationListener<PresenceEventUserPresence> {
private String topic;
public String getTopic() {
return topic;
}
public Class<PresenceEventUserPresence> getEventBodyClass() {
return PresenceEventUserPresence.class;
}
@Override
// The problem is on this type. It shouldn't be `NotificationEvent<?>`, but `NotificationEvent<PresenceEventUserPresence>`
public void onEvent(NotificationEvent<?> event) {
// This would remove the necessity to cast the `event.getEventBody()` here ↓
System.out.println("system presence -> " + ((PresenceEventUserPresence)event.getEventBody()).getPresenceDefinition().getSystemPresence());
}
public UserPresenceListener(String userId) {
this.topic = "v2.users." + userId + ".presence";
}
}
I hope the comments I added in the code explain better the situation.
------------------------------
Gaël BLAISE
National Bank of Canada
------------------------------
Original Message:
Sent: 08-18-2025 12:01
From: Jerome Saint-Marc
Subject: Please, fix the incoherent use of generics in the Java SDK
Hello,
Have you also already seen this section of the Java SDK README (paragraph named "Handle incoming notification events")?
The generic is meant to manage the different topic events (defined as classes in the Java SDK) listed in the Available Topics page. The notificationMappings.json file can be useful to find what class represents which topic.
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 08-15-2025 17:42
From: Gaël BLAISE
Subject: Please, fix the incoherent use of generics in the Java SDK
Hello,
While reading through the code, and using the SDK I came across the NotificationListener interface (link to the file, in the latest release: 229.0.0).
My point is the following: why is this interface marked as generically typed (NotificationListener<T>), when its methods do not returned object type with its type (T) but as ?.
In fact it says "hey I listen to notifications of type Exemple, but I will receive a notification of an unknown type (Object), where I should receive an Exemple notification". This doesn't seem coherent at all.
For this specific interface I would expect it to be like this:
package com.mypurecloud.sdk.v2.extensions.notifications;public interface NotificationListener<T> { String getTopic(); Class<T> getEventBodyClass(); void onEvent(NotificationEvent<T> event);}
This would be much more logical / coherent.
By the way, I didn't dig in the code, but I think it should be fixed in all other interfaces/classes, if the same kind of thing happens anywhere else…
Thank you in advance for your response.
#PlatformSDK
------------------------------
Gaël BLAISE
National Bank of Canada
------------------------------