public class UserChannelDao<U extends User,C extends Channel> extends Object implements Closeable
All methods will throw a NullPointerException
when any argument is
null
Modifier and Type | Method and Description |
---|---|
boolean |
channelExists(String name)
Deprecated.
Renamed
containsChannel(java.lang.String) to match
the Java Collections API |
void |
close()
Clears all internal maps
|
boolean |
containsChannel(String name)
Check if we are currently in the given channel
|
boolean |
containsUser(String nick)
Check if user exists by nick
|
boolean |
containsUser(UserHostmask hostmask)
Check if user exists by hostmask
|
C |
createChannel(String name)
Creates a known channel, internally called when we join a channel
|
UserChannelDaoSnapshot |
createSnapshot()
Create an immutable snapshot (copy) of all of contained Users, Channels,
and mappings, VERY EXPENSIVE.
|
U |
createUser(UserHostmask userHostmask)
Create a user from a hostmask, internally called when a valid, real user
contacts us
|
com.google.common.collect.ImmutableSortedSet<C> |
getAllChannels()
Get all currently joined channels
|
com.google.common.collect.ImmutableSortedSet<U> |
getAllUsers()
Get all currently known users, except from just joined channels where the
WHO response hasn't finished (listen for
UserListEvent instead) |
C |
getChannel(String name)
Lookup channel by name, throwing a
DaoException if not found |
com.google.common.collect.ImmutableSortedSet<C> |
getChannels(U user)
Get channels we're joined to that the user is joined to as well
|
com.google.common.collect.ImmutableSortedSet<C> |
getChannels(U user,
UserLevel level)
Gets all currently known channels the user is a part of with the
specified level.
|
com.google.common.collect.ImmutableSortedSet<UserLevel> |
getLevels(C channel,
U user)
Gets all currently known levels (op/voice/etc) a user holds in the
channel.
|
com.google.common.collect.ImmutableSortedSet<C> |
getNormalUserChannels(U user)
Gets all currently known channels the user is a part of as a normal user.
|
com.google.common.collect.ImmutableSortedSet<U> |
getNormalUsers(C channel)
Gets all currently known users in a channel who do not hold a UserLevel
(op/voice/etc).
|
U |
getUser(String nick)
Lookup user by nick, throwing a
DaoException if not found |
U |
getUser(UserHostmask userHostmask)
Lookup user by UserHostmask, throwing a
DaoException if not found |
User |
getUserBot()
Gets the bots own user object.
|
com.google.common.collect.ImmutableSortedSet<U> |
getUsers(C channel)
Get all currently known users in a channel
|
com.google.common.collect.ImmutableSortedSet<U> |
getUsers(C channel,
UserLevel level)
Gets all currently known users in a channel that hold the specified
UserLevel.
|
boolean |
userExists(String nick)
Deprecated.
Renamed
containsUser(java.lang.String) to match
Java Collections API |
public U getUser(@NonNull String nick) throws DaoException
DaoException
if not foundnick
- The nick of the userUser
DaoException
- If user does not exist, exception will contain
DaoException.Reason.UNKNOWN_USER
and the
nick that doesn't existpublic U getUser(@NonNull UserHostmask userHostmask)
DaoException
if not founduserHostmask
- The hostmask of the userUser
DaoException
- If user does not exist, exception will contain
DaoException.Reason.UNKNOWN_USER_HOSTMASK
,
hostmask, and wrapped exception with nickpublic U createUser(@NonNull UserHostmask userHostmask)
userHostmask
- The hostmask of the userUser
that was created@Deprecated public boolean userExists(@NonNull String nick)
containsUser(java.lang.String)
to match
Java Collections APIcontainsUser(java.lang.String)
public boolean containsUser(@NonNull String nick)
nick
- Nick of userpublic boolean containsUser(@NonNull UserHostmask hostmask)
hostmask
- Hostmask of userpublic com.google.common.collect.ImmutableSortedSet<U> getAllUsers()
UserListEvent
instead)UserListEvent
public com.google.common.collect.ImmutableSortedSet<U> getNormalUsers(@NonNull C channel)
UserListEvent
for the channel must of been
dispatched before this method will return complete resultschannel
- Known channelpublic com.google.common.collect.ImmutableSortedSet<U> getUsers(@NonNull C channel, @NonNull UserLevel level)
UserListEvent
for the channel must of been
dispatched before this method will return complete resultschannel
- Known channellevel
- Level users must holdpublic com.google.common.collect.ImmutableSortedSet<UserLevel> getLevels(@NonNull C channel, @NonNull U user)
UserListEvent
for the channel must of been dispatched
before this method will return complete resultschannel
- Known channeluser
- Known userpublic com.google.common.collect.ImmutableSortedSet<C> getNormalUserChannels(@NonNull U user)
UserListEvent
for all channels must of been dispatched before
this method will return complete resultsuser
- Known userpublic com.google.common.collect.ImmutableSortedSet<C> getChannels(@NonNull U user, @NonNull UserLevel level)
UserListEvent
for all channels must of been
dispatched before this method will return complete resultsuser
- Known userpublic C getChannel(@NonNull String name) throws DaoException
DaoException
if not foundname
- Name of channel (eg #pircbotx)DaoException
public C createChannel(@NonNull String name)
name
- @Deprecated public boolean channelExists(@NonNull String name)
containsChannel(java.lang.String)
to match
the Java Collections APIcontainsChannel(java.lang.String)
public boolean containsChannel(@NonNull String name)
name
- Channel name (eg #pircbotx)public com.google.common.collect.ImmutableSortedSet<U> getUsers(@NonNull C channel)
channel
- Known channelpublic com.google.common.collect.ImmutableSortedSet<C> getAllChannels()
public com.google.common.collect.ImmutableSortedSet<C> getChannels(@NonNull U user)
user
- A known userpublic User getUserBot()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public UserChannelDaoSnapshot createSnapshot()
Copyright © 2010–2020 Leon Blakey. All rights reserved.