mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
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.
This commit is contained in:
parent
62916b8490
commit
07da9ffb48
65 changed files with 207 additions and 121 deletions
|
@ -555,7 +555,7 @@ public final class OpenPgpManager extends Manager {
|
|||
Async.go(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
OpenPgpElement element = message.getExtension(OpenPgpElement.ELEMENT, OpenPgpElement.NAMESPACE);
|
||||
OpenPgpElement element = message.getExtension(OpenPgpElement.class);
|
||||
if (element == null) {
|
||||
// Message does not contain an OpenPgpElement -> discard
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus, 2018 Paul Schaub.
|
||||
* Copyright 2017-2020 Florian Schmaus, 2018 Paul Schaub.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.ox.element;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -38,6 +40,7 @@ public class OpenPgpElement implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "openpgp";
|
||||
public static final String NAMESPACE = "urn:xmpp:openpgp:0";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
// Represents the OpenPGP message, but encoded using base64.
|
||||
private final String base64EncodedOpenPgpMessage;
|
||||
|
@ -70,6 +73,11 @@ public class OpenPgpElement implements ExtensionElement {
|
|||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getQName() {
|
||||
return QNAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
|
@ -78,6 +86,6 @@ public class OpenPgpElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static OpenPgpElement fromStanza(Stanza stanza) {
|
||||
return stanza.getExtension(ELEMENT, NAMESPACE);
|
||||
return stanza.getExtension(OpenPgpElement.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue