From d498cd849918b14218f8c922f525e2cf23bf01b2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 12 Apr 2020 12:13:32 +0200 Subject: [PATCH] core: re-add Stanza.getExtension(String, String) and mark deprecated This method was removed with 07da9ffb4 ("Do not have Stanza.getExtension(String, String) return a generic type"). In order to aide migration to the newer API, this commit re-adds the method and marks it as deprecated. --- .../org/jivesoftware/smack/packet/Stanza.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java index 2e8123ec8..2422db010 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java @@ -369,6 +369,22 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement { return packetExtension; } + /** + * This method is deprecated. Use preferably {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)}. + * + * @param the type to cast to. + * @param elementName the XML element name of the extension. (May be null) + * @param namespace the XML element namespace of the extension. + * @return the extension, or null if it doesn't exist. + * @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} isntead. + */ + // TODO: Remove in Smack 4.5. + @SuppressWarnings("unchecked") + @Deprecated + public final E getExtension(String elementName, String namespace) { + return (E) getExtensionElement(elementName, namespace); + } + @Override public final ExtensionElement getExtension(QName qname) { synchronized (extensionElements) {