Class ItemEventFactory

    • Constructor Detail

      • ItemEventFactory

        public ItemEventFactory()
        Constructs a new ItemEventFactory.
    • Method Detail

      • createCommandEvent

        public static ItemCommandEvent createCommandEvent​(String itemName,
                                                          Command command,
                                                          String source)
        Creates an item command event.
        Parameters:
        itemName - the name of the item to send the command for
        command - the command to send
        source - the name of the source identifying the sender (can be null)
        Returns:
        the created item command event
        Throws:
        IllegalArgumentException - if itemName or command is null
      • createCommandEvent

        public static ItemCommandEvent createCommandEvent​(String itemName,
                                                          Command command)
        Creates an item command event.
        Parameters:
        itemName - the name of the item to send the command for
        command - the command to send
        Returns:
        the created item command event
        Throws:
        IllegalArgumentException - if itemName or command is null
      • createStateEvent

        public static ItemStateEvent createStateEvent​(String itemName,
                                                      State state,
                                                      String source)
        Creates an item state event.
        Parameters:
        itemName - the name of the item to send the state update for
        state - the new state to send
        source - the name of the source identifying the sender (can be null)
        Returns:
        the created item state event
        Throws:
        IllegalArgumentException - if itemName or state is null
      • createStateEvent

        public static ItemStateEvent createStateEvent​(String itemName,
                                                      State state)
        Creates an item state event.
        Parameters:
        itemName - the name of the item to send the state update for
        state - the new state to send
        Returns:
        the created item state event
        Throws:
        IllegalArgumentException - if itemName or state is null
      • createStatePredictedEvent

        public static ItemStatePredictedEvent createStatePredictedEvent​(String itemName,
                                                                        State state,
                                                                        boolean isConfirmation)
        Creates an item state predicted event.
        Parameters:
        itemName - the name of the item to send the state update for
        state - the predicted state to send
        isConfirmation - whether this is a confirmation of a previous state
        Returns:
        the created item state predicted event
        Throws:
        IllegalArgumentException - if itemName or state is null
      • createStateChangedEvent

        public static ItemStateChangedEvent createStateChangedEvent​(String itemName,
                                                                    State newState,
                                                                    State oldState)
        Creates an item state changed event.
        Parameters:
        itemName - the name of the item to send the state changed event for
        newState - the new state to send
        oldState - the old state of the item
        Returns:
        the created item state changed event
        Throws:
        IllegalArgumentException - if itemName or state is null
      • createAddedEvent

        public static ItemAddedEvent createAddedEvent​(Item item)
        Creates an item added event.
        Parameters:
        item - the item
        Returns:
        the created item added event
        Throws:
        IllegalArgumentException - if item is null
      • createRemovedEvent

        public static ItemRemovedEvent createRemovedEvent​(Item item)
        Creates an item removed event.
        Parameters:
        item - the item
        Returns:
        the created item removed event
        Throws:
        IllegalArgumentException - if item is null
      • createUpdateEvent

        public static ItemUpdatedEvent createUpdateEvent​(Item item,
                                                         Item oldItem)
        Creates an item updated event.
        Parameters:
        item - the item
        oldItem - the old item
        Returns:
        the created item updated event
        Throws:
        IllegalArgumentException - if item or oldItem is null