mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-17 00:11:07 +01: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
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
|
|
@ -34,6 +36,7 @@ public class DelayInformationManager {
|
|||
|
||||
public static final String LEGACY_DELAYED_DELIVERY_NAMESPACE = "jabber:x:delay";
|
||||
public static final String LEGACY_DELAYED_DELIVERY_ELEMENT = "x";
|
||||
public static final QName QNAME = new QName(LEGACY_DELAYED_DELIVERY_NAMESPACE, LEGACY_DELAYED_DELIVERY_ELEMENT);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +60,7 @@ public class DelayInformationManager {
|
|||
* @return the Delayed Delivery information or <code>null</code>
|
||||
*/
|
||||
public static DelayInformation getLegacyDelayInformation(Stanza packet) {
|
||||
return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
|
@ -39,6 +41,7 @@ import org.jxmpp.util.XmppDateTime;
|
|||
public class DelayInformation implements ExtensionElement {
|
||||
public static final String ELEMENT = "delay";
|
||||
public static final String NAMESPACE = "urn:xmpp:delay";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final Date stamp;
|
||||
private final String from;
|
||||
|
|
@ -129,6 +132,6 @@ public class DelayInformation implements ExtensionElement {
|
|||
* @return the DelayInformation or null
|
||||
*/
|
||||
public static DelayInformation from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue