Package org.openhab.core.items
Class GroupItem
java.lang.Object
org.openhab.core.items.GenericItem
org.openhab.core.items.GroupItem
- All Implemented Interfaces:
- Identifiable<String>,- ActiveItem,- Item,- MetadataAwareItem,- StateChangeListener
@NonNullByDefault
public class GroupItem
extends GenericItem
implements StateChangeListener, MetadataAwareItem
- Author:
- Kai Kreuzer - Initial contribution
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final @Nullable Itemprotected @Nullable GroupFunctionprotected final CopyOnWriteArrayList<Item> static final StringFields inherited from class org.openhab.core.items.GenericItemcategory, eventPublisher, groupNames, itemStateConverter, label, lastState, lastStateChange, lastStateUpdate, listeners, name, state, tags, timeSeriesListeners, type
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddedMetadata(Metadata metadata) Can be implemented by subclasses to be informed about added metadatavoidAdds the given item to the members of this group item.voiddispose()Disposes this item.The accepted command types of a group item is the same as of the underlying base item.The accepted data types of a group item is the same as of the underlying base item.@Nullable ItemReturns the base item of thisGroupItem.@Nullable GroupFunctionReturns the function of thisGroupItem.getMembers(Predicate<Item> filterItem) Retrieves ALL members of this group and filters it with the given Predicate<T extends State>
 @Nullable TgetStateAs(Class<T> typeClass) returns the current state of the item as a specific typeprotected voidinternalSend(Command command, @Nullable String source) voidRemoves all items from the members of this group item.voidremovedMetadata(Metadata metadata) Can be implemented by subclasses to be informed about removed metadatavoidremoveMember(Item item) Removes the given item from the members of this group item.voidreplaceMember(Item oldItem, Item newItem) voidSend a command to the each member of the group.voidSend a command to the each member of the group.voidsetCommandDescriptionService(@Nullable CommandDescriptionService commandDescriptionService) voidSet a new state.voidsetStateDescriptionService(@Nullable StateDescriptionService stateDescriptionService) voidstateChanged(Item item, State oldState, State newState) This method is called, if a state has changed.voidstateUpdated(Item item, State state) This method is called, if a state was updated, but has not changedtoString()voidupdatedMetadata(Metadata oldMetadata, Metadata newMetadata) Can be implemented by subclasses to be informed about updated metadataMethods inherited from class org.openhab.core.items.GenericItemaddGroupName, addGroupNames, addGroupNames, addStateChangeListener, addTag, addTags, addTags, addTimeSeriesListener, applyState, applyTimeSeries, equals, getCategory, getCommandDescription, getCommandOptions, getGroupNames, getLabel, getLastState, getLastStateChange, getLastStateUpdate, getName, getState, getStateDescription, getStateDescription, getTags, getType, getUID, hashCode, hasTag, isAcceptedState, logSetTypeError, logSetTypeError, notifyListeners, removeAllTags, removeGroupName, removeStateChangeListener, removeTag, removeTimeSeriesListener, send, send, setCategory, setEventPublisher, setItemStateConverter, setLabel, setState, setState, setTimeSeriesMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openhab.core.items.ItemgetCommandDescription
- 
Field Details- 
TYPE- See Also:
 
- 
baseItem
- 
function
- 
members
 
- 
- 
Constructor Details- 
GroupItemCreates a plain GroupItem- Parameters:
- name- name of the group
 
- 
GroupItem
- 
GroupItemCreates a GroupItem with function- Parameters:
- name- name of the group
- baseItem- type of items in the group
- function- function to calculate group status out of member status
 
 
- 
- 
Method Details- 
disposepublic void dispose()Description copied from class:GenericItemDisposes 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.- Overrides:
- disposein class- GenericItem
 
- 
getBaseItemReturns the base item of thisGroupItem. This method is only intended to allow instance checks of the underlying BaseItem. It must not be changed in any way.- Returns:
- the base item of this GroupItem
 
- 
getFunctionReturns the function of thisGroupItem.- Returns:
- the function of this GroupItem
 
- 
getMembers- Returns:
- the direct members of this GroupItem
 
- 
getAllMembersReturns the direct members of thisGroupItemand recursively all members of the potentially containedGroupItems as well. TheGroupItems itself aren't contained. The returned items are unique.- Returns:
- all members of this and all contained GroupItems
 
- 
getAllStateMembersReturns the direct members of thisGroupItemand recursively all members of the potentially containedGroupItems as well. TheGroupItems itself are contained if they can have a state. The returned items are unique.- Returns:
- all members of this and all contained GroupItems
 
- 
getMembersRetrieves ALL members of this group and filters it with the given Predicate- Parameters:
- filterItem- Predicate with settings to filter member list
- Returns:
- Set of member items filtered by filterItem
 
- 
addMemberAdds the given item to the members of this group item.- Parameters:
- item- the item to be added (must not be null)
- Throws:
- IllegalArgumentException- if the given item is null
 
- 
replaceMember
- 
removeMemberRemoves the given item from the members of this group item.- Parameters:
- item- the item to be removed (must not be null)
- Throws:
- IllegalArgumentException- if the given item is null
 
- 
removeAllMemberspublic void removeAllMembers()Removes all items from the members of this group item.
- 
getAcceptedDataTypesThe accepted data types of a group item is the same as of the underlying base item. If none is defined, the intersection of all sets of accepted data types of all group members is used instead.- Specified by:
- getAcceptedDataTypesin interface- Item
- Returns:
- the accepted data types of this group item
 
- 
getAcceptedCommandTypesThe accepted command types of a group item is the same as of the underlying base item. If none is defined, the intersection of all sets of accepted command types of all group members is used instead.- Specified by:
- getAcceptedCommandTypesin interface- Item
- Returns:
- the accepted command types of this group item
 
- 
sendSend a command to the each member of the group.- Parameters:
- command- the command to be sent
 
- 
sendSend a command to the each member of the group.- Parameters:
- command- the command to be sent
- source- the source of the command. See https://www.openhab.org/docs/developer/utils/events.html#the-core-events
 
- 
internalSend- Overrides:
- internalSendin class- GenericItem
 
- 
getStateAsDescription copied from interface:Itemreturns the current state of the item as a specific type- Specified by:
- getStateAsin interface- Item
- Overrides:
- getStateAsin class- GenericItem
- Returns:
- the current state in the requested type or null, if state cannot be provided as the requested type
 
- 
toString- Overrides:
- toStringin class- GenericItem
 
- 
stateChangedDescription copied from interface:StateChangeListenerThis method is called, if a state has changed.- Specified by:
- stateChangedin interface- StateChangeListener
- Parameters:
- item- the item whose state has changed
- oldState- the previous state
- newState- the new state
 
- 
stateUpdatedDescription copied from interface:StateChangeListenerThis method is called, if a state was updated, but has not changed- Specified by:
- stateUpdatedin interface- StateChangeListener
- Parameters:
- item- the item whose state was updated
- state- the current state, same before and after the update
 
- 
setStateDescription copied from class:GenericItemSet a new state. Subclasses may override this method in order to do necessary conversions upfront. Afterwards,GenericItem.applyState(State, String)should be called by classes overriding this method.- Overrides:
- setStatein class- GenericItem
- Parameters:
- state- new state of this item
- source- the source of the state update. See https://www.openhab.org/docs/developer/utils/events.html#the-core-events
 
- 
setStateDescriptionService- Overrides:
- setStateDescriptionServicein class- GenericItem
 
- 
setCommandDescriptionServicepublic void setCommandDescriptionService(@Nullable CommandDescriptionService commandDescriptionService) - Overrides:
- setCommandDescriptionServicein class- GenericItem
 
- 
addedMetadataDescription copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about added metadata- Specified by:
- addedMetadatain interface- MetadataAwareItem
- Parameters:
- metadata- the added- Metadataobject for this- Item
 
- 
updatedMetadataDescription copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about updated metadata- Specified by:
- updatedMetadatain interface- MetadataAwareItem
- Parameters:
- oldMetadata- the old- Metadataobject for this- Item
- newMetadata- the new- Metadataobject for this- Item
 
- 
removedMetadataDescription copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about removed metadata- Specified by:
- removedMetadatain interface- MetadataAwareItem
- Parameters:
- metadata- the removed- Metadataobject for this- Item
 
 
-