1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

[sinttest] Improve code readability in MultiUserChatOccupantIntegrationTest

Especially considering pattern matching for instanceof, which will be
available in Java 16.
This commit is contained in:
Florian Schmaus 2024-10-18 15:46:06 +02:00
parent 9c7e575e9e
commit 7e8fddcbf8

View file

@ -114,8 +114,13 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
final List<Stanza> results = new ArrayList<>(); final List<Stanza> results = new ArrayList<>();
final StanzaListener stanzaListener = stanza -> { final StanzaListener stanzaListener = stanza -> {
results.add(stanza); results.add(stanza);
if (stanza instanceof Message && ((Message) stanza).getSubject() != null) { // TODO: Use pattern matching for instanceof once Smack is Java 16 or higher.
subjectResultSyncPoint.signal(((Message) stanza).getSubject()); if (stanza instanceof Message) {
Message message = (Message) stanza;
String subject = message.getSubject();
if (subject != null) {
subjectResultSyncPoint.signal(subject);
}
} }
}; };
conTwo.addStanzaListener(stanzaListener, FromMatchesFilter.create(mucAddress)); conTwo.addStanzaListener(stanzaListener, FromMatchesFilter.create(mucAddress));