Commit Graph

7 Commits

Author SHA1 Message Date
Florian Schmaus b09cd06053 [core] Use XmppElementUtil.castOrThrow() in StanzaView.getExtension(Class)
This means that users get now exceptions with helpful error messages
instead of the dreaded ClassCastException, like

java.lang.ClassCastException: org.jivesoftware.smack.packet.StandardExtensionElement cannot be cast to org.jivesoftware.smackx.mam.element.MamElements$MamResultExtension
at

when StanzaView.getExtension(Class) is used to retrieve the extension.
2020-08-29 16:29:22 +02:00
Florian Schmaus 5e921e6393 core: add javadoc for StanzaView.getExtensions(Class) 2020-04-18 22:56:10 +02:00
Florian Schmaus 2c83c73005 core: Avoid ClassCastException in getExtension(Class)
Ensure that he returned extension element is actually of the correct
type. It should not be common, but in theory, Smack's provider
architecture would allow for different types to be returned than the
ones one may expect.
2020-04-11 18:04:15 +02:00
Florian Schmaus 07da9ffb48 Do not have Stanza.getExtension(String, String) return a generic type
Returning a generic would allow for

List<ExtensionElement> list = stanza.getExtension("foo", "bar");

to compile (Note the we are calling getExtension(), not
getExtension*s*()).

Users are encouraged to use the type safe getExtension(Class<? extends
ExtensionElement) variant instead.

Fixes SMACK-825.
2020-04-05 22:10:05 +02:00
Florian Schmaus 8d432e2303 Add StanzaView.hasExtension(Class<? extends ExtensionElement>) 2020-04-05 19:59:24 +02:00
Florian Schmaus e2d206e741 Introduce XMPPConnection.add(Message|Presence)Interceptor
add deprecate addStanzaInterceptor().
2019-10-25 21:41:55 +02:00
Florian Schmaus 5db6191110 Introduce StanzaBuilder
As first step to immutable Stanza types.
2019-10-25 21:41:55 +02:00