Class MessageSelector<M1,​M2>

  • All Implemented Interfaces:
    MessageProcessor<java.lang.Object,​M2>

    public abstract class MessageSelector<M1,​M2>
    extends java.lang.Object
    implements MessageProcessor<java.lang.Object,​M2>
    A fluent interface for creating MessageProcessors that select messages matching a few simple criteria.
    • Method Detail

      • select

        public static <M> MessageSelector<java.lang.Object,​M> select()
        Creates a new MessageSelector.
        Returns:
        A new MessageSelector that selects all messages.
      • ofType

        public <M extends M1MessageSelector<M1,​M> ofType​(java.lang.Class<M> type)
        Selects messages of the given class.
        Parameters:
        type - The class of the messages to select.
        Returns:
        a new MessageSelector that selects messages of the given class.
      • matches

        protected abstract boolean matches​(M1 m)
      • process

        public final M2 process​(java.lang.Object m)
        Description copied from interface: MessageProcessor
        An implementation of this method is used to select messages off an actor's queue for the purpose of selective receive. If the message is selected (i.e. it should be processed now), then this method should return a non-null value. If the message is to be skipped, this method should return null. The value returned by this method, will be returned by the receive method this instance has been passed to.

        If the message is selected, this method may process it (and may even call receive for nested selective receives), or it may choose to return the message and have it processed when it is returned from the enclosing receive.

        Specified by:
        process in interface MessageProcessor<M1,​M2>
        Parameters:
        m - The message
        Returns:
        A non-null value if the message is selected; null if the message is to be skipped.