public class ObjectMessage<T> extends Message
| Constructor and Description |
|---|
ObjectMessage(T content)
Builds a message with the specified content
|
| Modifier and Type | Method and Description |
|---|---|
T |
getContent()
Gets the content of this message
|
static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> |
max(java.util.Collection<M> messageCollection)
Returns the message containing the maximum element of the given collection, according to the natural ordering
of the elements contained in the message.
|
static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> |
min(java.util.Collection<M> messageCollection)
Returns the message containing the minimum element of the given collection, according to the natural ordering
of the elements contained in the message.
|
static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> |
sort(java.util.List<M> list)
Sorts the specified list of messages into ascending order, according to the natural ordering
of the content of each message.
|
java.lang.String |
toString() |
clone, getConversationID, getReceiver, getSenderpublic ObjectMessage(T content)
content - public T getContent()
public static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> M max(java.util.Collection<M> messageCollection)
This method iterates over the entire collection, hence it requires time proportional to the size of the collection.
messageCollection - the collection of messages whose maximum element is to be determined.java.lang.ClassCastException - if the content of the messages are not mutually comparable.java.util.NoSuchElementException - if the collection is empty.Comparablepublic static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> M min(java.util.Collection<M> messageCollection)
This method iterates over the entire collection, hence it requires time proportional to the size of the collection.
messageCollection - the collection of messages whose maximum element is to be determined.java.lang.ClassCastException - if the content of the messages are not mutually comparable.java.util.NoSuchElementException - if the collection is empty.Comparablepublic static <T extends java.lang.Object & java.lang.Comparable<? super T>,M extends ObjectMessage<T>> void sort(java.util.List<M> list)
Comparable
interface. Furthermore, all these elements must be mutually comparable (that is, e1.compareTo(e2) must
not throw a ClassCastException for any elements e1 and e2 in the list).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The specified list must be modifiable, but need not be resizable.
list - the list to be sorted.java.lang.ClassCastException - if the list contains elements that are not mutually comparable (for example, strings and
integers).java.lang.UnsupportedOperationException - if the specified list's list-iterator does not support the set operation.java.lang.IllegalArgumentException - (optional) if the implementation detects that the natural ordering of the list elements is found to
violate the Comparable contractpublic java.lang.String toString()
toString in class MessageMessage.toString()
Fabien Michel, Olivier Gutknecht, Jacques Ferber - September 9 2019