Package madkit.message
Class ObjectMessage<T>
java.lang.Object
madkit.kernel.Message
madkit.message.ObjectMessage<T>
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
BooleanMessage
,EnumMessage
,HookMessage
,IntegerMessage
,MapMessage
,StringMessage
This parameterizable class could be used to convey any Java Object between MaDKit agents.
- Since:
- MaDKit 5.0.0.1
- Version:
- 0.9
- Author:
- Fabien Michel
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the content of this messagestatic <T extends Object & Comparable<? super T>,
M extends ObjectMessage<T>>
Mmax
(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>>
Mmin
(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>>
voidSorts the specified list of messages into ascending order, according to the natural ordering of the content of each message.toString()
Methods inherited from class madkit.kernel.Message
clone, getConversationID, getReceiver, getSender
-
Constructor Details
-
ObjectMessage
Builds a message with the specified content- Parameters:
content
-
-
-
Method Details
-
getContent
Gets the content of this message- Returns:
- the object of type T contained in the message
-
max
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> M 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. All elements in the messages must implement the Comparable interface. Furthermore, all elements must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the collection).This method iterates over the entire collection, hence it requires time proportional to the size of the collection.
- Parameters:
messageCollection
- the collection of messages whose maximum element is to be determined.- Returns:
- the message containing the maximum element.
- Throws:
ClassCastException
- if the content of the messages are not mutually comparable.NoSuchElementException
- if the collection is empty.- See Also:
-
min
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> M 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. All elements in the messages must implement the Comparable interface. Furthermore, all elements must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the collection).This method iterates over the entire collection, hence it requires time proportional to the size of the collection.
- Parameters:
messageCollection
- the collection of messages whose maximum element is to be determined.- Returns:
- the message containing the minimum element.
- Throws:
ClassCastException
- if the content of the messages are not mutually comparable.NoSuchElementException
- if the collection is empty.- See Also:
-
sort
public static <T extends Object & Comparable<? super T>,M extends ObjectMessage<T>> void sort(List<M> list) Sorts the specified list of messages into ascending order, according to the natural ordering of the content of each message. All elements contained in the messages must implement theComparable
interface. Furthermore, all these elements must be mutually comparable (that is,e1.compareTo(e2)
must not throw aClassCastException
for any elementse1
ande2
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.
- Parameters:
list
- the list to be sorted.- Throws:
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 theset
operation.IllegalArgumentException
- (optional) if the implementation detects that the natural ordering of the list elements is found to violate theComparable
contract
-
toString
-