1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Add Stanza.hasStanzaIdSet()

This commit is contained in:
Florian Schmaus 2015-02-08 11:50:07 +01:00
parent 1190edad0f
commit e0a2441c62

View file

@ -119,6 +119,9 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
* @param id the unique ID for the packet. * @param id the unique ID for the packet.
*/ */
public void setStanzaId(String id) { public void setStanzaId(String id) {
if (id != null) {
requireNotNullOrEmpty(id, "id must either be null or not the empty String");
}
this.id = id; this.id = id;
} }
@ -132,6 +135,18 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
setStanzaId(packetID); setStanzaId(packetID);
} }
/**
* Check if this stanza has an ID set.
*
* @return true if the stanza ID is set, false otherwise.
* @since 4.1
*/
public boolean hasStanzaIdSet() {
// setStanzaId ensures that the id is either null or not empty,
// so we can assume that it is set if it's not null.
return id != null;
}
/** /**
* Returns who the packet is being sent "to", or <tt>null</tt> if * Returns who the packet is being sent "to", or <tt>null</tt> if
* the value is not set. The XMPP protocol often makes the "to" * the value is not set. The XMPP protocol often makes the "to"