- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<MessageInfo>
,Collection<MessageInfo>
,List<MessageInfo>
,RandomAccess
This class is an implementation of ArrayList used to store the
Message
in a Chat
.
The messages stored in this collection are guaranteed to be stored chronologically.
This contract can be technically broken using reflection to access the array associated with this collection, though, obviously, it's not advisable.- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorDescriptionMessages()
Messages
(@NonNull MessageInfo message) Constructs a new instance of WebMessageInfos from a WebMessageInfo -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index, MessageInfo element) This method is not supported for this collection because of the contract previously explainedboolean
add
(@NonNull MessageInfo message) Addsmessage
to this collection in the right position in order to respect the contract explained previouslyboolean
addAll
(int index, Collection<? extends MessageInfo> c) This method is not supported for this collection because of the contract previously explainedboolean
addAll
(Collection<? extends MessageInfo> collection) Adds each entry ofcollection
if no other entry in this collection has an jid that matches said entry's.boolean
addOrReplace
(@NonNull MessageInfo message) Addsmessage
if no other entry in this collection has an jid that matches the one ofmessage
.Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
-
Constructor Details
-
Messages
Constructs a new instance of WebMessageInfos from a WebMessageInfo- Parameters:
message
- the first non null entry to add to this collection
-
Messages
public Messages()
-
-
Method Details
-
add
Addsmessage
to this collection in the right position in order to respect the contract explained previously- Specified by:
add
in interfaceCollection<MessageInfo>
- Specified by:
add
in interfaceList<MessageInfo>
- Overrides:
add
in classArrayList<MessageInfo>
- Parameters:
message
- the non null message to add to this collection- Returns:
- true if
message
was added successfully
-
addOrReplace
Addsmessage
if no other entry in this collection has an jid that matches the one ofmessage
. Otherwise, it removes said entry and addsmessage
.- Parameters:
message
- the non null message to add to this collection- Returns:
- true if
message
was replaced
-
addAll
Adds each entry ofcollection
if no other entry in this collection has an jid that matches said entry's. Otherwise, it removes said entry and adds said entry.- Specified by:
addAll
in interfaceCollection<MessageInfo>
- Specified by:
addAll
in interfaceList<MessageInfo>
- Overrides:
addAll
in classArrayList<MessageInfo>
- Parameters:
collection
- the collection to add to this collection
-
add
This method is not supported for this collection because of the contract previously explained- Specified by:
add
in interfaceList<MessageInfo>
- Overrides:
add
in classArrayList<MessageInfo>
- Throws:
UnsupportedOperationException
- this exception will always be thrown
-
addAll
This method is not supported for this collection because of the contract previously explained- Specified by:
addAll
in interfaceList<MessageInfo>
- Overrides:
addAll
in classArrayList<MessageInfo>
- Throws:
UnsupportedOperationException
- this exception will always be thrown
-