Package org.javacord.api.util.event
Interface ListenerManager<T>
-
- Type Parameters:
T- The listener class.
public interface ListenerManager<T>This class can be used to edit added listeners afterwards.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddRemoveHandler(java.lang.Runnable removeHandler)Adds a runnable which gets called when the listener gets removed.java.util.Optional<java.lang.Class<?>>getAssignedObjectClass()Gets the class of the object, the listener was added to.java.util.Optional<java.lang.Long>getAssignedObjectId()Gets the id of the object, the listener as added to.TgetListener()Gets the managed listener.java.lang.Class<T>getListenerClass()Gets the listener class context for the managed listener.booleanisGlobalListener()Checks if the managed listener is a global listener.ListenerManager<T>remove()Removes the listener.ListenerManager<T>removeAfter(long delay, java.util.concurrent.TimeUnit timeUnit)Removes the listener after the given delay.
-
-
-
Method Detail
-
isGlobalListener
boolean isGlobalListener()
Checks if the managed listener is a global listener.- Returns:
- Whether the managed listener is a global listener or not.
-
getListenerClass
java.lang.Class<T> getListenerClass()
Gets the listener class context for the managed listener.- Returns:
- The listener class context for the managed listener.
-
getListener
T getListener()
Gets the managed listener.- Returns:
- The managed listener.
-
getAssignedObjectClass
java.util.Optional<java.lang.Class<?>> getAssignedObjectClass()
Gets the class of the object, the listener was added to. For global listeners, it returns an emptyOptional.- Returns:
- The class of the object, the listener was added to.
-
getAssignedObjectId
java.util.Optional<java.lang.Long> getAssignedObjectId()
Gets the id of the object, the listener as added to. Empty for global listeners.- Returns:
- The id of the object, the listener was added to.
-
remove
ListenerManager<T> remove()
Removes the listener.- Returns:
- The current instance in order to chain call methods.
-
removeAfter
ListenerManager<T> removeAfter(long delay, java.util.concurrent.TimeUnit timeUnit)
Removes the listener after the given delay.- Parameters:
delay- The time to wait before removing the listener.timeUnit- The time unit of the delay.- Returns:
- The current instance in order to chain call methods.
-
addRemoveHandler
void addRemoveHandler(java.lang.Runnable removeHandler)
Adds a runnable which gets called when the listener gets removed.- Parameters:
removeHandler- The handler which gets called when the listener gets remove.
-
-