Class GenericItem

    • Constructor Detail

      • GenericItem

        public GenericItem​(String type,
                           String name)
    • Method Detail

      • getState

        public State getState()
        Description copied from interface: Item
        returns the current state of the item
        Specified by:
        getState in interface Item
        Returns:
        the current state
      • getStateAs

        public <T extends State> @Nullable T getStateAs​(Class<T> typeClass)
        Description copied from interface: Item
        returns the current state of the item as a specific type
        Specified by:
        getStateAs in interface Item
        Returns:
        the current state in the requested type or null, if state cannot be provided as the requested type
      • getName

        public String getName()
        Description copied from interface: Item
        returns the name of the item
        Specified by:
        getName in interface Item
        Returns:
        the name of the item
      • getType

        public String getType()
        Description copied from interface: Item
        returns the item type as defined by ItemFactorys
        Specified by:
        getType in interface Item
        Returns:
        the item type
      • getGroupNames

        public List<String> getGroupNames()
        Description copied from interface: Item
        Returns a list of the names of the groups this item belongs to.
        Specified by:
        getGroupNames in interface Item
        Returns:
        list of item group names
      • addGroupNames

        public void addGroupNames​(String... groupItemNames)
        Description copied from interface: ActiveItem
        Assigns the according item to the given groups.
        Specified by:
        addGroupNames in interface ActiveItem
        Parameters:
        groupItemNames - names of the groups (must not be null)
      • addGroupNames

        public void addGroupNames​(List<String> groupItemNames)
        Description copied from interface: ActiveItem
        Assigns the according item to the given groups.
        Specified by:
        addGroupNames in interface ActiveItem
        Parameters:
        groupItemNames - names of the groups (must not be null)
      • dispose

        public void dispose()
        Disposes this item. Clears all injected services and unregisters all change listeners. This does not remove this item from its groups. Removing from groups should be done externally to retain the member order in case this item is exchanged in a group.
      • setEventPublisher

        public void setEventPublisher​(@Nullable EventPublisher eventPublisher)
      • setStateDescriptionService

        public void setStateDescriptionService​(@Nullable StateDescriptionService stateDescriptionService)
      • setCommandDescriptionService

        public void setCommandDescriptionService​(@Nullable CommandDescriptionService commandDescriptionService)
      • setUnitProvider

        public void setUnitProvider​(@Nullable UnitProvider unitProvider)
      • setItemStateConverter

        public void setItemStateConverter​(@Nullable ItemStateConverter itemStateConverter)
      • internalSend

        protected void internalSend​(Command command)
      • setState

        public void setState​(State state)
        Set a new state. Subclasses may override this method in order to do necessary conversions upfront. Afterwards, applyState(State) should be called by classes overriding this method.
        Parameters:
        state - new state of this item
      • applyState

        protected final void applyState​(State state)
        Sets new state, notifies listeners and sends events. Classes overriding the setState(State) method should call this method in order to actually set the state, inform listeners and send the event.
        Parameters:
        state - new state of this item
      • notifyListeners

        protected void notifyListeners​(State oldState,
                                       State newState)
      • addStateChangeListener

        public void addStateChangeListener​(StateChangeListener listener)
      • removeStateChangeListener

        public void removeStateChangeListener​(StateChangeListener listener)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(@Nullable Object obj)
        Overrides:
        equals in class Object
      • getTags

        public Set<String> getTags()
        Description copied from interface: Item
        Returns a set of tags. If the item is not tagged, an empty set is returned.
        Specified by:
        getTags in interface Item
        Returns:
        set of tags.
      • hasTag

        public boolean hasTag​(String tag)
        Description copied from interface: Item
        Returns true if the item's tags contains the specific tag, otherwise false.
        Specified by:
        hasTag in interface Item
        Parameters:
        tag - a tag whose presence in the item's tags is to be tested.
        Returns:
        true if the item's tags contains the specific tag, otherwise false.
      • addTag

        public void addTag​(String tag)
        Description copied from interface: ActiveItem
        Adds a tag to the item.
        Specified by:
        addTag in interface ActiveItem
        Parameters:
        tag - a tag that is to be added to item's tags.
      • addTags

        public void addTags​(Collection<String> tags)
        Description copied from interface: ActiveItem
        Adds tags to the item.
        Specified by:
        addTags in interface ActiveItem
        Parameters:
        tags - tags that are to be added to item's tags.
      • addTags

        public void addTags​(String... tags)
        Description copied from interface: ActiveItem
        Adds tags to the item.
        Specified by:
        addTags in interface ActiveItem
        Parameters:
        tags - tags that are to be added to item's tags.
      • removeTag

        public void removeTag​(String tag)
        Description copied from interface: ActiveItem
        Removes a tag from the item.
        Specified by:
        removeTag in interface ActiveItem
        Parameters:
        tag - a tag that is to be removed from item's tags.
      • removeAllTags

        public void removeAllTags()
        Description copied from interface: ActiveItem
        Clears all tags of this item.
        Specified by:
        removeAllTags in interface ActiveItem
      • getLabel

        public @Nullable String getLabel()
        Description copied from interface: Item
        Returns the label of the item or null if no label is set.
        Specified by:
        getLabel in interface Item
        Returns:
        item label or null
      • setLabel

        public void setLabel​(@Nullable String label)
        Description copied from interface: ActiveItem
        Sets the label of an item
        Specified by:
        setLabel in interface ActiveItem
        Parameters:
        label - label (can be null)
      • getCategory

        public @Nullable String getCategory()
        Description copied from interface: Item
        Returns the category of the item or null if no category is set.
        Specified by:
        getCategory in interface Item
        Returns:
        category or null
      • setCategory

        public void setCategory​(@Nullable String category)
        Description copied from interface: ActiveItem
        Sets the category of the item (can be null)
        Specified by:
        setCategory in interface ActiveItem
        Parameters:
        category - category
      • getStateDescription

        public @Nullable StateDescription getStateDescription()
        Description copied from interface: Item
        Returns the first provided state description (uses the default locale). If options are defined on the channel, they are included in the returned state description.
        Specified by:
        getStateDescription in interface Item
        Returns:
        state description (can be null)
      • getStateDescription

        public @Nullable StateDescription getStateDescription​(@Nullable Locale locale)
        Description copied from interface: Item
        Returns the first provided state description for a given locale. If options are defined on the channel, they are included in the returned state description.
        Specified by:
        getStateDescription in interface Item
        Parameters:
        locale - locale (can be null)
        Returns:
        state description (can be null)
      • isAcceptedState

        public boolean isAcceptedState​(List<Class<? extends State>> acceptedDataTypes,
                                       State state)
        Tests if state is within acceptedDataTypes list or a subclass of one of them
        Parameters:
        acceptedDataTypes - list of datatypes this items accepts as a state
        state - to be tested
        Returns:
        true if state is an acceptedDataType or subclass thereof
      • logSetTypeError

        protected void logSetTypeError​(State state)