mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Add Stanza.hasStanzaIdSet()
This commit is contained in:
parent
1190edad0f
commit
e0a2441c62
1 changed files with 15 additions and 0 deletions
|
@ -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"
|
||||||
|
|
Loading…
Reference in a new issue