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 Object & Comparable<? super T>,M extends ObjectMessage<T>> |
max(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 Object & Comparable<? super T>,M extends ObjectMessage<T>> |
min(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 Object & Comparable<? super T>,M extends ObjectMessage<T>> |
sort(List<M> list)
Sorts the specified list of messages into ascending order, according to the
natural ordering of the content of each message.
|
String |
toString() |
clone, getConversationID, getReceiver, getSender
public ObjectMessage(T content)
content
- public T getContent()
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> M max(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.ClassCastException
- if the content of the messages are
not mutually comparable.NoSuchElementException
- if the collection is empty.Comparable
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> M min(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.ClassCastException
- if the content of the messages are
not mutually comparable.NoSuchElementException
- if the collection is empty.Comparable
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> void sort(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.ClassCastException
- if the list contains elements that are not
mutually comparable (for example, strings and integers).UnsupportedOperationException
- if the specified list's
list-iterator does not support the set
operation.IllegalArgumentException
- (optional) if the implementation
detects that the natural ordering of the list elements is
found to violate the Comparable
contractpublic String toString()
toString
in class Message
Message.toString()
Fabien Michel, Olivier Gutknecht, Jacques Ferber