private Item createItemFromModelItem(ModelItem modelItem) { GenericItem item = null; if (modelItem instanceof ModelGroupItem) { ModelGroupItem modelGroupItem = (ModelGroupItem) modelItem; String baseItemType = modelGroupItem.getType(); GenericItem baseItem = createItemOfType(baseItemType, modelGroupItem.getName()); if (baseItem != null) { ModelGroupFunction function = modelGroupItem.getFunction(); if (function == null) { item = new GroupItem(modelGroupItem.getName(), baseItem); } else { item = applyGroupFunction(baseItem, modelGroupItem, function); } } else { item = new GroupItem(modelGroupItem.getName()); } } else { ModelNormalItem normalItem = (ModelNormalItem) modelItem; String itemName = normalItem.getName(); item = createItemOfType(normalItem.getType(), itemName); } if (item != null) { String label = modelItem.getLabel(); String format = StringUtils.substringBetween(label, "[", "]"); if (format != null) { label = StringUtils.substringBefore(label, "[").trim(); stateDescriptions.put( modelItem.getName(), new StateDescription(null, null, null, format, false, null)); } item.setLabel(label); item.setCategory(modelItem.getIcon()); assignTags(modelItem, item); return item; } else { return null; } }