Class PrivacyList

  • All Implemented Interfaces:
    Comparable<PrivacyList>

    public final class PrivacyList
    extends Object
    implements Comparable<PrivacyList>
    The implementation of a privacy list.

    2. Protocol

    Most instant messaging systems have found it necessary to implement some method for users to block communications from particular other users (this is also required by sections 5.1.5, 5.1.15, 5.3.2, and 5.4.10 of RFC 2779 [3]. In XMPP this is done by managing one's privacy lists using the 'jabber:iq:privacy' namespace.

    This class is immutable.
    See Also:
    XEP-0016: Privacy Lists
    • Constructor Detail

      • PrivacyList

        public PrivacyList​(String name,
                           Collection<PrivacyRule> items)
        Creates a privacy list with rules.
        Parameters:
        name - The privacy list's name.
        items - The privacy rules.
      • PrivacyList

        public PrivacyList​(String name)
        Creates a privacy list.
        Parameters:
        name - The privacy list's name.
    • Method Detail

      • createInvisibilityList

        public static PrivacyList createInvisibilityList()
        Creates a global invisibility list.
        Returns:
        The invisibility list.
      • createInvisibilityListForUsers

        public static PrivacyList createInvisibilityListForUsers​(String listName,
                                                                 Jid... jids)
        Creates a selective invisibility list. You are only invisible to the provided JIDs. You are visible to everyone else.
        Parameters:
        listName - The list name. See 4. Implementation Notes for recommended list names.
        jids - The JIDs to which you appear invisible.
        Returns:
        The invisibility list.
        See Also:
        XEP-0126: Invisibility, 3.4.1 Becoming Invisible by JID
      • getPrivacyRules

        public final List<PrivacyRule> getPrivacyRules()
        Gets the privacy rules.
        Returns:
        The privacy rules.
      • getName

        public final String getName()
        Gets the name of the privacy list.
        Returns:
        The name.
      • isDefault

        public final boolean isDefault()
        Indicates whether this is the default list.
        Returns:
        True, if this is the default list.
      • isActive

        public final boolean isActive()
        Indicates whether this is the active list.
        Returns:
        True, if this is the active list.
      • asActive

        public final PrivacyList asActive()
        Gets the privacy list marked as active list.
        Returns:
        The list as active list.
        See Also:
        isActive()
      • asDefault

        public final PrivacyList asDefault()
        Gets the privacy list marked as default list.
        Returns:
        The privacy list as default list.
        See Also:
        isDefault()
      • compareTo

        public final int compareTo​(PrivacyList o)
        Compares this privacy list with another list. When sorted, default lists are listed first, then active lists, then lists are sorted by their name.
        Specified by:
        compareTo in interface Comparable<PrivacyList>
        Parameters:
        o - The other list.
        Returns:
        The comparison result.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object