Package org.openhab.core.items
Interface ItemBuilder
@NonNullByDefault
public interface ItemBuilder
This class allows the easy construction of an
Item
using the builder pattern.- Author:
- Simon Kaufmann - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates an item with the currently configured values.withBaseItem
(@Nullable Item baseItem) Set the base item..withCategory
(@Nullable String category) Set the category of the item.withGroupFunction
(@Nullable GroupFunction function) Set the group functionwithGroups
(@Nullable Collection<String> groups) Set the group membership of the item.Set the label of the item.Set the tags
-
Method Details
-
build
Item build()Creates an item with the currently configured values.- Returns:
- an item
- Throws:
IllegalStateException
- in case no item factory can create the given item type
-
withLabel
Set the label of the item.- Parameters:
label
- the label- Returns:
- the builder itself
-
withGroups
Set the group membership of the item.- Parameters:
groups
- the group names the item belongs to- Returns:
- the builder itself
-
withCategory
Set the category of the item.- Parameters:
category
- the category- Returns:
- the builder itself
-
withBaseItem
Set the base item..- Parameters:
baseItem
- the base item- Returns:
- the builder itself
- Throws:
IllegalArgumentException
- in case this is not a group item
-
withGroupFunction
Set the group function- Parameters:
function
- the group function- Returns:
- the builder itself
- Throws:
IllegalArgumentException
- in case this is not a group item
-
withTags
Set the tags- Parameters:
tags
- the tags- Returns:
- the builder itself
-