1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-16 04:12:04 +01:00

Improve HostedRoom API

return EntityBareJid instead of Jid.
This commit is contained in:
Florian Schmaus 2015-07-17 09:06:40 +02:00
parent 7032688123
commit 2e03f0f3f3

View file

@ -16,8 +16,9 @@
*/ */
package org.jivesoftware.smackx.muc; package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smackx.disco.packet.DiscoverItems; import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.EntityBareJid;
/** /**
* Hosted rooms by a chat service may be discovered if they are configured to appear in the room * Hosted rooms by a chat service may be discovered if they are configured to appear in the room
@ -32,12 +33,13 @@ import org.jxmpp.jid.Jid;
*/ */
public class HostedRoom { public class HostedRoom {
private final Jid jid; private final EntityBareJid jid;
private final String name; private final String name;
public HostedRoom(DiscoverItems.Item item) { public HostedRoom(DiscoverItems.Item item) {
jid = item.getEntityID(); jid = Objects.requireNonNull(item.getEntityID().asEntityBareJidIfPossible(),
"The discovered item must be an entity bare JID");
name = item.getName(); name = item.getName();
} }
@ -47,7 +49,7 @@ public class HostedRoom {
* *
* @return the XMPP address of the hosted room by the chat service. * @return the XMPP address of the hosted room by the chat service.
*/ */
public Jid getJid() { public EntityBareJid getJid() {
return jid; return jid;
} }