Package org.javacord.core.entity.message
Class MessageSetImpl
- java.lang.Object
-
- org.javacord.core.entity.message.MessageSetImpl
-
- All Implemented Interfaces:
Iterable<Message>
,Collection<Message>
,NavigableSet<Message>
,Set<Message>
,SortedSet<Message>
,MessageSet
public class MessageSetImpl extends Object implements MessageSet
The implementation ofMessageSet
.
-
-
Constructor Summary
Constructors Constructor Description MessageSetImpl(Collection<Message> messages)
Creates a new message set.MessageSetImpl(NavigableSet<Message> messages)
Creates a new message set.MessageSetImpl(Message... messages)
Creates a new message set.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Message message)
boolean
addAll(Collection<? extends Message> c)
Message
ceiling(Message message)
void
clear()
Comparator<? super Message>
comparator()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
Iterator<Message>
descendingIterator()
NavigableSet<Message>
descendingSet()
Message
first()
Message
floor(Message message)
static CompletableFuture<MessageSet>
getMessages(TextChannel channel, int limit)
Gets up to a given amount of messages in the given channel from the newer end.static CompletableFuture<MessageSet>
getMessagesAfter(TextChannel channel, int limit, long after)
Gets up to a given amount of messages in the given channel after a given message in any channel.static Stream<Message>
getMessagesAfterAsStream(TextChannel channel, long after)
Gets a stream of messages in the given channel after a given message in any channel sorted from oldest to newest.static CompletableFuture<MessageSet>
getMessagesAfterUntil(TextChannel channel, Predicate<Message> condition, long after)
Gets messages in the given channel after a given message in any channel until one that meets the given condition is found.static CompletableFuture<MessageSet>
getMessagesAfterWhile(TextChannel channel, Predicate<Message> condition, long after)
Gets messages in the given channel after a given message in any channel while they meet the given condition.static CompletableFuture<MessageSet>
getMessagesAround(TextChannel channel, int limit, long around)
Gets up to a given amount of messages in the given channel around a given message in any channel.static Stream<Message>
getMessagesAroundAsStream(TextChannel channel, long around)
Gets a stream of messages in the given channel around a given message in any channel.static CompletableFuture<MessageSet>
getMessagesAroundUntil(TextChannel channel, Predicate<Message> condition, long around)
Gets messages in the given channel around a given message in any channel until one that meets the given condition is found.static CompletableFuture<MessageSet>
getMessagesAroundWhile(TextChannel channel, Predicate<Message> condition, long around)
Gets messages in the given channel around a given message in any channel while they meet the given condition.static Stream<Message>
getMessagesAsStream(TextChannel channel)
Gets a stream of messages in the given channel sorted from newest to oldest.static CompletableFuture<MessageSet>
getMessagesBefore(TextChannel channel, int limit, long before)
Gets up to a given amount of messages in the given channel before a given message in any channel.static Stream<Message>
getMessagesBeforeAsStream(TextChannel channel, long before)
Gets a stream of messages in the given channel before a given message in any channel sorted from newest to oldest.static CompletableFuture<MessageSet>
getMessagesBeforeUntil(TextChannel channel, Predicate<Message> condition, long before)
Gets messages in the given channel before a given message in any channel until one that meets the given condition is found.static CompletableFuture<MessageSet>
getMessagesBeforeWhile(TextChannel channel, Predicate<Message> condition, long before)
Gets messages in the given channel before a given message in any channel while they meet the given condition.static CompletableFuture<MessageSet>
getMessagesBetween(TextChannel channel, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries.static Stream<Message>
getMessagesBetweenAsStream(TextChannel channel, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, sorted from first given message to the second given message.static CompletableFuture<MessageSet>
getMessagesBetweenUntil(TextChannel channel, Predicate<Message> condition, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, until one that meets the given condition is found.static CompletableFuture<MessageSet>
getMessagesBetweenWhile(TextChannel channel, Predicate<Message> condition, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, while they meet the given condition.static CompletableFuture<MessageSet>
getMessagesUntil(TextChannel channel, Predicate<Message> condition)
Gets messages in the given channel from the newer end until one that meets the given condition is found.static CompletableFuture<MessageSet>
getMessagesWhile(TextChannel channel, Predicate<Message> condition)
Gets messages in the given channel from the newer end while they meet the given condition.MessageSet
headSet(Message toElement)
MessageSet
headSet(Message toElement, boolean inclusive)
Message
higher(Message message)
boolean
isEmpty()
Iterator<Message>
iterator()
Message
last()
Message
lower(Message message)
Message
pollFirst()
Message
pollLast()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
MessageSet
subSet(Message fromElement, boolean fromInclusive, Message toElement, boolean toInclusive)
MessageSet
subSet(Message fromElement, Message toElement)
MessageSet
tailSet(Message fromElement)
MessageSet
tailSet(Message fromElement, boolean inclusive)
Object[]
toArray()
<T> T[]
toArray(T[] a)
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface org.javacord.api.entity.message.MessageSet
deleteAll, getNewestMessage, getOldestMessage
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.SortedSet
spliterator
-
-
-
-
Constructor Detail
-
MessageSetImpl
public MessageSetImpl(NavigableSet<Message> messages)
Creates a new message set.- Parameters:
messages
- The messages to be contained in this set.
-
MessageSetImpl
public MessageSetImpl(Collection<Message> messages)
Creates a new message set.- Parameters:
messages
- The messages to be contained in this set.
-
MessageSetImpl
public MessageSetImpl(Message... messages)
Creates a new message set.- Parameters:
messages
- The messages to be contained in this set.
-
-
Method Detail
-
getMessages
public static CompletableFuture<MessageSet> getMessages(TextChannel channel, int limit)
Gets up to a given amount of messages in the given channel from the newer end.- Parameters:
channel
- The channel of the messages.limit
- The limit of messages to get.- Returns:
- The messages.
- See Also:
getMessagesAsStream(TextChannel)
-
getMessagesUntil
public static CompletableFuture<MessageSet> getMessagesUntil(TextChannel channel, Predicate<Message> condition)
Gets messages in the given channel from the newer end until one that meets the given condition is found. If no message matches the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The abort condition for when to stop retrieving messages.- Returns:
- The messages.
- See Also:
getMessagesAsStream(TextChannel)
-
getMessagesWhile
public static CompletableFuture<MessageSet> getMessagesWhile(TextChannel channel, Predicate<Message> condition)
Gets messages in the given channel from the newer end while they meet the given condition. If the first message does not match the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The condition that has to be met.- Returns:
- The messages.
- See Also:
getMessagesAsStream(TextChannel)
-
getMessagesAsStream
public static Stream<Message> getMessagesAsStream(TextChannel channel)
Gets a stream of messages in the given channel sorted from newest to oldest.The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.
- Parameters:
channel
- The channel of the messages.- Returns:
- The stream.
- See Also:
getMessages(TextChannel, int)
-
getMessagesBefore
public static CompletableFuture<MessageSet> getMessagesBefore(TextChannel channel, int limit, long before)
Gets up to a given amount of messages in the given channel before a given message in any channel.- Parameters:
channel
- The channel of the messages.limit
- The limit of messages to get.before
- Get messages before the message with this id.- Returns:
- The messages.
- See Also:
getMessagesBeforeAsStream(TextChannel, long)
-
getMessagesBeforeUntil
public static CompletableFuture<MessageSet> getMessagesBeforeUntil(TextChannel channel, Predicate<Message> condition, long before)
Gets messages in the given channel before a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The abort condition for when to stop retrieving messages.before
- Get messages before the message with this id.- Returns:
- The messages.
- See Also:
getMessagesBeforeAsStream(TextChannel, long)
-
getMessagesBeforeWhile
public static CompletableFuture<MessageSet> getMessagesBeforeWhile(TextChannel channel, Predicate<Message> condition, long before)
Gets messages in the given channel before a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The condition that has to be met.before
- Get messages before the message with this id.- Returns:
- The messages.
- See Also:
getMessagesBeforeAsStream(TextChannel, long)
-
getMessagesBeforeAsStream
public static Stream<Message> getMessagesBeforeAsStream(TextChannel channel, long before)
Gets a stream of messages in the given channel before a given message in any channel sorted from newest to oldest.The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.
- Parameters:
channel
- The channel of the messages.before
- Get messages before the message with this id.- Returns:
- The stream.
- See Also:
getMessagesBefore(TextChannel, int, long)
-
getMessagesAfter
public static CompletableFuture<MessageSet> getMessagesAfter(TextChannel channel, int limit, long after)
Gets up to a given amount of messages in the given channel after a given message in any channel.- Parameters:
channel
- The channel of the messages.limit
- The limit of messages to get.after
- Get messages after the message with this id.- Returns:
- The messages.
- See Also:
getMessagesAfterAsStream(TextChannel, long)
-
getMessagesAfterUntil
public static CompletableFuture<MessageSet> getMessagesAfterUntil(TextChannel channel, Predicate<Message> condition, long after)
Gets messages in the given channel after a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The abort condition for when to stop retrieving messages.after
- Get messages after the message with this id.- Returns:
- The messages.
- See Also:
getMessagesAfterAsStream(TextChannel, long)
-
getMessagesAfterWhile
public static CompletableFuture<MessageSet> getMessagesAfterWhile(TextChannel channel, Predicate<Message> condition, long after)
Gets messages in the given channel after a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The condition that has to be met.after
- Get messages after the message with this id.- Returns:
- The messages.
- See Also:
getMessagesAfterAsStream(TextChannel, long)
-
getMessagesAfterAsStream
public static Stream<Message> getMessagesAfterAsStream(TextChannel channel, long after)
Gets a stream of messages in the given channel after a given message in any channel sorted from oldest to newest.The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.
- Parameters:
channel
- The channel of the messages.after
- Get messages after the message with this id.- Returns:
- The stream.
- See Also:
getMessagesAfter(TextChannel, int, long)
-
getMessagesAround
public static CompletableFuture<MessageSet> getMessagesAround(TextChannel channel, int limit, long around)
Gets up to a given amount of messages in the given channel around a given message in any channel. The given message will be part of the result in addition to the messages around if it was sent in the given channel and does not count towards the limit. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the actual amount of messages will be less than the given limit. It's also not guaranteed to be perfectly balanced.- Parameters:
channel
- The channel of the messages.limit
- The limit of messages to get.around
- Get messages around the message with this id.- Returns:
- The messages.
- See Also:
getMessagesAroundAsStream(TextChannel, long)
-
getMessagesAroundUntil
public static CompletableFuture<MessageSet> getMessagesAroundUntil(TextChannel channel, Predicate<Message> condition, long around)
Gets messages in the given channel around a given message in any channel until one that meets the given condition is found. If no message matches the condition, an empty set is returned. The given message will be part of the result in addition to the messages around if it was sent in the given channel and is matched against the condition and will abort retrieval. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the halves will not be same-sized. It's also not guaranteed to be perfectly balanced.- Parameters:
channel
- The channel of the messages.condition
- The abort condition for when to stop retrieving messages.around
- Get messages around the message with this id.- Returns:
- The messages.
-
getMessagesAroundWhile
public static CompletableFuture<MessageSet> getMessagesAroundWhile(TextChannel channel, Predicate<Message> condition, long around)
Gets messages in the given channel around a given message in any channel while they meet the given condition. If the first message does not match the condition, an empty set is returned. The given message will be part of the result in addition to the messages around if it was sent in the given channel and is matched against the condition and will abort retrieval. Half of the messages will be older than the given message and half of the messages will be newer. If there aren't enough older or newer messages, the halves will not be same-sized. It's also not guaranteed to be perfectly balanced.- Parameters:
channel
- The channel of the messages.condition
- The condition that has to be met.around
- Get messages around the message with this id.- Returns:
- The messages.
-
getMessagesAroundAsStream
public static Stream<Message> getMessagesAroundAsStream(TextChannel channel, long around)
Gets a stream of messages in the given channel around a given message in any channel. The first message in the stream will be the given message if it was sent in the given channel. After that you will always get an older message and a newer message alternating as long as on both sides messages are available. If only on one side further messages are available, only those are delivered further on. It's not guaranteed to be perfectly balanced.The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.
- Parameters:
channel
- The channel of the messages.around
- Get messages around the message with this id.- Returns:
- The stream.
- See Also:
getMessagesAround(TextChannel, int, long)
-
getMessagesBetween
public static CompletableFuture<MessageSet> getMessagesBetween(TextChannel channel, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries. Gets up to a given amount of messages in the given channel before a given message in any channel.- Parameters:
channel
- The channel of the messages.from
- The id of the start boundary messages.to
- The id of the other boundary messages.- Returns:
- The messages.
- See Also:
getMessagesBetweenAsStream(TextChannel, long, long)
-
getMessagesBetweenUntil
public static CompletableFuture<MessageSet> getMessagesBetweenUntil(TextChannel channel, Predicate<Message> condition, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, until one that meets the given condition is found. If no message matches the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The abort condition for when to stop retrieving messages.from
- The id of the start boundary messages.to
- The id of the other boundary messages.- Returns:
- The messages.
- See Also:
getMessagesBetweenAsStream(TextChannel, long, long)
-
getMessagesBetweenWhile
public static CompletableFuture<MessageSet> getMessagesBetweenWhile(TextChannel channel, Predicate<Message> condition, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, while they meet the given condition. If the first message does not match the condition, an empty set is returned.- Parameters:
channel
- The channel of the messages.condition
- The condition that has to be met.from
- The id of the start boundary messages.to
- The id of the other boundary messages.- Returns:
- The messages.
- See Also:
getMessagesBetweenAsStream(TextChannel, long, long)
-
getMessagesBetweenAsStream
public static Stream<Message> getMessagesBetweenAsStream(TextChannel channel, long from, long to)
Gets all messages in the given channel between the first given message in any channel and the second given message in any channel, excluding the boundaries, sorted from first given message to the second given message.The messages are retrieved in batches synchronously from Discord, so consider not using this method from a listener directly.
- Parameters:
channel
- The channel of the messages.from
- The id of the start boundary messages.to
- The id of the other boundary messages.- Returns:
- The stream.
- See Also:
getMessagesBetween(TextChannel, long, long)
-
lower
public Message lower(Message message)
- Specified by:
lower
in interfaceNavigableSet<Message>
-
floor
public Message floor(Message message)
- Specified by:
floor
in interfaceNavigableSet<Message>
-
ceiling
public Message ceiling(Message message)
- Specified by:
ceiling
in interfaceNavigableSet<Message>
-
higher
public Message higher(Message message)
- Specified by:
higher
in interfaceNavigableSet<Message>
-
pollFirst
public Message pollFirst()
- Specified by:
pollFirst
in interfaceNavigableSet<Message>
-
pollLast
public Message pollLast()
- Specified by:
pollLast
in interfaceNavigableSet<Message>
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public boolean add(Message message)
-
remove
public boolean remove(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<Message>
- Specified by:
containsAll
in interfaceSet<Message>
-
addAll
public boolean addAll(Collection<? extends Message> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
clear
public void clear()
-
descendingSet
public NavigableSet<Message> descendingSet()
- Specified by:
descendingSet
in interfaceNavigableSet<Message>
-
descendingIterator
public Iterator<Message> descendingIterator()
- Specified by:
descendingIterator
in interfaceNavigableSet<Message>
-
subSet
public MessageSet subSet(Message fromElement, boolean fromInclusive, Message toElement, boolean toInclusive)
- Specified by:
subSet
in interfaceMessageSet
- Specified by:
subSet
in interfaceNavigableSet<Message>
-
subSet
public MessageSet subSet(Message fromElement, Message toElement)
- Specified by:
subSet
in interfaceMessageSet
- Specified by:
subSet
in interfaceNavigableSet<Message>
- Specified by:
subSet
in interfaceSortedSet<Message>
-
headSet
public MessageSet headSet(Message toElement, boolean inclusive)
- Specified by:
headSet
in interfaceMessageSet
- Specified by:
headSet
in interfaceNavigableSet<Message>
-
headSet
public MessageSet headSet(Message toElement)
- Specified by:
headSet
in interfaceMessageSet
- Specified by:
headSet
in interfaceNavigableSet<Message>
- Specified by:
headSet
in interfaceSortedSet<Message>
-
tailSet
public MessageSet tailSet(Message fromElement, boolean inclusive)
- Specified by:
tailSet
in interfaceMessageSet
- Specified by:
tailSet
in interfaceNavigableSet<Message>
-
tailSet
public MessageSet tailSet(Message fromElement)
- Specified by:
tailSet
in interfaceMessageSet
- Specified by:
tailSet
in interfaceNavigableSet<Message>
- Specified by:
tailSet
in interfaceSortedSet<Message>
-
comparator
public Comparator<? super Message> comparator()
- Specified by:
comparator
in interfaceSortedSet<Message>
-
-