Class AbstractPlatformConnection

  • All Implemented Interfaces:
    PlatformConnection

    public abstract class AbstractPlatformConnection
    extends java.lang.Object
    implements PlatformConnection
    Describes an abstract platform connection, a helper class to cover holding instantiations for chats and users in the system in weak reference caches, a memory-tolerant behavior that ensures one-reference for a platform connection.
    • Constructor Detail

      • AbstractPlatformConnection

        public AbstractPlatformConnection()
    • Method Detail

      • clearChatMap

        protected final void clearChatMap()
        Clears the chat map, used to persist Chat objects in the Platform.
      • clearUserMap

        protected final void clearUserMap()
        Clears the user map, used to persist PlatformUser objects in the Platform.
      • loadUserById

        protected abstract PlatformUser loadUserById​(java.lang.String id)
        Loads a user by its ID.
        Parameters:
        id - PlatformUser ID to load.
        Returns:
        PlatformUser instance loaded, null otherwise.
      • loadChatById

        protected abstract Chat loadChatById​(java.lang.String id)
        Loads a chat by its ID.
        Parameters:
        id - Chat ID to load.
        Returns:
        Chat instance loaded, null otherwise.
      • getCachedUserById

        protected final PlatformUser getCachedUserById​(java.lang.String id)
      • getCachedChatById

        protected final Chat getCachedChatById​(java.lang.String id)
      • getCachedUserById

        protected final PlatformUser getCachedUserById​(java.lang.String id,
                                                       java.util.function.Function<java.lang.String,​PlatformUser> function)
      • getCachedChatById

        protected final Chat getCachedChatById​(java.lang.String id,
                                               java.util.function.Function<java.lang.String,​Chat> function)
      • getChat

        public Chat getChat​(java.lang.String id)
        Description copied from interface: PlatformConnection
        Gets a chat by its user-specific ID.
        Specified by:
        getChat in interface PlatformConnection
        Parameters:
        id - Chat ID to search for.
        Returns:
        Chat instance if found, null otherwise.
      • getPlatformUser

        public PlatformUser getPlatformUser​(java.lang.String id)
        Description copied from interface: PlatformConnection
        Gets a user on this platform by their platform-specific ID.
        Specified by:
        getPlatformUser in interface PlatformConnection
        Parameters:
        id - platform-specific Id.
        Returns:
        PlatformUser instance if found, null otherwise.
      • getChats

        public java.util.Collection<Chat> getChats()
        Description copied from interface: PlatformConnection
        Gets a list of chats associated with this platform.
        Specified by:
        getChats in interface PlatformConnection
        Returns:
        immutable collection of Chat instances associated with this platform.