Add convinient constructors for Message and Presence

This commit is contained in:
Florian Schmaus 2016-10-31 12:24:03 +01:00
parent 9331a4c677
commit 5a2326a856
2 changed files with 25 additions and 0 deletions

View File

@ -114,6 +114,18 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
this(JidCreate.from(to), body);
}
/**
* Creates a new message with the specified recipient and extension element.
*
* @param to
* @param extensionElement
* @since 4.2
*/
public Message(Jid to, ExtensionElement extensionElement) {
this(to);
addExtension(extensionElement);
}
/**
* Copy constructor.
* <p>

View File

@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
/**
* Represents XMPP presence packets. Every presence stanza(/packet) has a type, which is one of
@ -78,6 +79,18 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
setType(type);
}
/**
* Creates a new presence with the given type and using the given XMPP address as recipient.
*
* @param to the recipient.
* @param type the type.
* @since 4.2
*/
public Presence(Jid to, Type type) {
this(type);
setTo(to);
}
/**
* Creates a new presence update with a specified status, priority, and mode.
*