org.eclipse.smarthome.core.items.Item.getTags()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(65)

本文整理了Java中org.eclipse.smarthome.core.items.Item.getTags()方法的一些代码示例,展示了Item.getTags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getTags()方法的具体详情如下:
包路径:org.eclipse.smarthome.core.items.Item
类名称:Item
方法名:getTags

Item.getTags介绍

[英]Returns a set of tags. If the item is not tagged, an empty set is returned.
[中]返回一组标记。如果项目未标记,则返回一个空集。

代码示例

代码示例来源:origin: eclipse/smarthome

@Override
protected PersistedItem toPersistableElement(Item item) {
  PersistedItem persistedItem = new PersistedItem(
      item instanceof GroupItem ? ITEM_TYPE_GROUP : toItemFactoryName(item));
  if (item instanceof GroupItem) {
    GroupItem groupItem = (GroupItem) item;
    String baseItemType = null;
    Item baseItem = groupItem.getBaseItem();
    if (baseItem != null) {
      baseItemType = toItemFactoryName(baseItem);
    }
    persistedItem.baseItemType = baseItemType;
    addFunctionToPersisedItem(persistedItem, groupItem);
  }
  persistedItem.label = item.getLabel();
  persistedItem.groupNames = new ArrayList<>(item.getGroupNames());
  persistedItem.tags = new HashSet<>(item.getTags());
  persistedItem.category = item.getCategory();
  return persistedItem;
}

代码示例来源:origin: eclipse/smarthome

public ItemBuilderImpl(Set<ItemFactory> itemFactories, Item item) {
  this.itemFactories = itemFactories;
  this.itemType = item.getType();
  this.name = item.getName();
  this.category = item.getCategory();
  this.groups = item.getGroupNames();
  this.label = item.getLabel();
  this.tags = item.getTags();
  if (item instanceof GroupItem) {
    this.baseItem = ((GroupItem) item).getBaseItem();
    this.groupFunction = ((GroupItem) item).getFunction();
  }
}

代码示例来源:origin: eclipse/smarthome

private static void fillProperties(ItemDTO itemDTO, Item item) {
  if (item instanceof GroupItem) {
    GroupItem groupItem = (GroupItem) item;
    GroupItemDTO groupItemDTO = (GroupItemDTO) itemDTO;
    if (groupItem.getBaseItem() != null) {
      groupItemDTO.groupType = groupItem.getBaseItem().getType();
      groupItemDTO.function = mapFunction(groupItem.getFunction());
    }
  }
  itemDTO.name = item.getName();
  itemDTO.type = item.getType();
  itemDTO.label = item.getLabel();
  itemDTO.tags = item.getTags();
  itemDTO.category = item.getCategory();
  itemDTO.groupNames = item.getGroupNames();
}

代码示例来源:origin: openhab/openhab-core

/**
 * Determines the Property that a Point relates to.
 *
 * @param item the item to get the property for
 * @return a sub-type of Property if the item represents a Point, otherwise null
 */
@SuppressWarnings("unchecked")
@Nullable
public static Class<? extends Property> getProperty(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && Property.class.isAssignableFrom(type)) {
      return (Class<? extends Property>) type;
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.smarthome.core/org.eclipse.smarthome.core.semantics

/**
 * Determines the Property that a Point relates to.
 *
 * @param item the item to get the property for
 * @return a sub-type of Property if the item represents a Point, otherwise null
 */
@SuppressWarnings("unchecked")
@Nullable
public static Class<? extends Property> getProperty(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && Property.class.isAssignableFrom(type)) {
      return (Class<? extends Property>) type;
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.smarthome.core/org.eclipse.smarthome.core.semantics

/**
 * Determines the semantic entity type of an item, i.e. a sub-type of Location, Equipment or Point.
 *
 * @param item the item to get the semantic type for
 * @return a sub-type of Location, Equipment or Point
 */
@Nullable
public static Class<? extends Tag> getSemanticType(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && !Property.class.isAssignableFrom(type)) {
      return type;
    }
  }
  // we haven't found any type as a tag, but if there is a Property tag, we can conclude that it is a Point
  if (getProperty(item) != null) {
    StateDescription stateDescription = item.getStateDescription();
    if (stateDescription != null && stateDescription.isReadOnly()) {
      return Measurement.class;
    } else {
      return Control.class;
    }
  } else {
    return null;
  }
}

代码示例来源:origin: openhab/openhab-core

/**
 * Determines the semantic entity type of an item, i.e. a sub-type of Location, Equipment or Point.
 *
 * @param item the item to get the semantic type for
 * @return a sub-type of Location, Equipment or Point
 */
@Nullable
public static Class<? extends Tag> getSemanticType(Item item) {
  Set<String> tags = item.getTags();
  for (String tag : tags) {
    Class<? extends Tag> type = getById(tag);
    if (type != null && !Property.class.isAssignableFrom(type)) {
      return type;
    }
  }
  // we haven't found any type as a tag, but if there is a Property tag, we can conclude that it is a Point
  if (getProperty(item) != null) {
    StateDescription stateDescription = item.getStateDescription();
    if (stateDescription != null && stateDescription.isReadOnly()) {
      return Measurement.class;
    } else {
      return Control.class;
    }
  } else {
    return null;
  }
}

代码示例来源:origin: openhab/openhab-core

@Override
protected PersistedItem toPersistableElement(Item item) {
  PersistedItem persistedItem = new PersistedItem(
      item instanceof GroupItem ? ITEM_TYPE_GROUP : toItemFactoryName(item));
  if (item instanceof GroupItem) {
    GroupItem groupItem = (GroupItem) item;
    String baseItemType = null;
    Item baseItem = groupItem.getBaseItem();
    if (baseItem != null) {
      baseItemType = toItemFactoryName(baseItem);
    }
    persistedItem.baseItemType = baseItemType;
    addFunctionToPersisedItem(persistedItem, groupItem);
  }
  persistedItem.label = item.getLabel();
  persistedItem.groupNames = new ArrayList<>(item.getGroupNames());
  persistedItem.tags = new HashSet<>(item.getTags());
  persistedItem.category = item.getCategory();
  return persistedItem;
}

代码示例来源:origin: openhab/openhab-core

public ItemBuilderImpl(Set<ItemFactory> itemFactories, Item item) {
  this.itemFactories = itemFactories;
  this.itemType = item.getType();
  this.name = item.getName();
  this.category = item.getCategory();
  this.groups = item.getGroupNames();
  this.label = item.getLabel();
  this.tags = item.getTags();
  if (item instanceof GroupItem) {
    this.baseItem = ((GroupItem) item).getBaseItem();
    this.groupFunction = ((GroupItem) item).getFunction();
  }
}

代码示例来源:origin: openhab/openhab-core

private static void fillProperties(ItemDTO itemDTO, Item item) {
  if (item instanceof GroupItem) {
    GroupItem groupItem = (GroupItem) item;
    GroupItemDTO groupItemDTO = (GroupItemDTO) itemDTO;
    if (groupItem.getBaseItem() != null) {
      groupItemDTO.groupType = groupItem.getBaseItem().getType();
      groupItemDTO.function = mapFunction(groupItem.getFunction());
    }
  }
  itemDTO.name = item.getName();
  itemDTO.type = item.getType();
  itemDTO.label = item.getLabel();
  itemDTO.tags = item.getTags();
  itemDTO.category = item.getCategory();
  itemDTO.groupNames = item.getGroupNames();
}

相关文章