public static JID fromJID(JID jid) {
        if (jid instanceof GroupJID || jid.getResource() == null || jid.getNode() == null) {
            return jid;
        } else {
            return (isGroup(jid)) ? new GroupJID(jid) : jid;
        }
    }
Returns a JID from the given JID. If the JID represents a group,
returns an instance of this class, otherwise returns the given JID.

@param jid A JID, possibly representing a group
@return A new GroupJID if the given JID represents a group, or the given JID
xmppserver/src/main/java/org/jivesoftware/openfire/group/GroupJID.java