Class MessageStoreSorted<M extends Message>

java.lang.Object
eu.bandm.tools.message.MessageStore_<M>
eu.bandm.tools.message.MessageStoreSorted<M>
Type Parameters:
M - the type of the messages
All Implemented Interfaces:
MessageReceiver<M>

public class MessageStoreSorted<M extends Message> extends MessageStore_<M>
Storage for a sequence of Messages with dynamic sorting.
  • Field Details

    • order

      @Opt protected @Opt Comparator<? super M extends Message> order
      If set, defines the storage order. Otherwise it is by arrival.
  • Constructor Details

    • MessageStoreSorted

      public MessageStoreSorted()
      Only constructor. Constructs a message store without indentation storage.
  • Method Details

    • setOrder

      public void setOrder(@Opt @Opt Comparator<? super M> comp)
      Set the comparator which rules the sequential order of storing. The current content will be re-ordered and the GUI models will be notified.
      Parameters:
      comp - the comparator to apply. If it is null, then no re-ordering takes place, and future messages will again be appended to the end of the store.
    • getOrder

      public Comparator<? super M> getOrder()
      Returns the comparator which rules the sequential order of storing.
      Returns:
      the comparator which rules the sequential order of storing.
    • receive

      public void receive(M message)
      Adds the received message to the internal store and notifies all GUI objects.

      If a comparator has been defined by setOrder(Comparator) then the new message is inserted directly before those which are of greater value, ie. after all those of equal value, which are older. In the absence of a comparator it is appended at the end.

      Specified by:
      receive in interface MessageReceiver<M extends Message>
      Specified by:
      receive in class MessageStore_<M extends Message>
      Parameters:
      message - the message to add to the score