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`

public class ObjectMessage<T> extends Message
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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ObjectMessage(T content)`
  Builds a message with the specified content

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `getContent()`
  Gets the content of this message
  `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.
  `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.
  `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.
  `String`
  `toString()`

  ### Methods inherited from class madkit.kernel.Message

  `clone, getConversationID, getReceiver, getSender`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ObjectMessage

    public ObjectMessage(T content)
    Builds a message with the specified content
    Parameters:
      `content` -

- ## Method Details

  - ### getContent

    public T 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:
      - `Comparable`

  - ### 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:
      - `Comparable`

  - ### 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 the `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.

    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 the `set` operation.
      `IllegalArgumentException` - (optional) if the implementation detects that the natural ordering of the list elements is found to violate the `Comparable` contract

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Message`
    See Also:
      - `Message.toString()`