org.openhab.core.items.Item.getAcceptedCommandTypes()方法的使用及代码示例

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

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

Item.getAcceptedCommandTypes介绍

[英]This method provides a list of all command types that can be used for this item

Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but also to turn OFF or ON. So the accepted command types would be in this case PercentType, OnOffType
[中]此方法提供可用于此项的所有命令类型的列表
例如,想象一个调光器设备:您可以要求它调暗到0%、10%、50%、100%,但也可以关闭或打开。因此,在本例中,接受的命令类型是PercentType,OnOffType

代码示例

代码示例来源:origin: openhab/openhab1-addons

/**
 * The 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.
 *
 * @return the accepted command types of this group item
 */
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends Command>> getAcceptedCommandTypes() {
  if (baseItem != null) {
    return baseItem.getAcceptedCommandTypes();
  } else {
    List<Class<? extends Command>> acceptedCommandTypes = null;
    for (Item item : members) {
      if (acceptedCommandTypes == null) {
        acceptedCommandTypes = item.getAcceptedCommandTypes();
      } else {
        acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
      }
    }
    return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes;
  }
}

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

/**
 * The 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.
 *
 * @return the accepted command types of this group item
 */
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends Command>> getAcceptedCommandTypes() {
  if (baseItem != null) {
    return baseItem.getAcceptedCommandTypes();
  } else {
    List<Class<? extends Command>> acceptedCommandTypes = null;
    for (Item item : members) {
      if (acceptedCommandTypes == null) {
        acceptedCommandTypes = item.getAcceptedCommandTypes();
      } else {
        acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
      }
    }
    return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes;
  }
}

代码示例来源:origin: org.openhab.binding/org.openhab.binding.nikobus

modules.put(moduleKey, module);
return ((ModuleChannelGroup) module).addChannel(item.getName(), channelNum, item.getAcceptedCommandTypes());

代码示例来源:origin: org.openhab.binding/org.openhab.binding.snmp

Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandAsString);
if (command == null) {
  logger.error("SNMP can't resolve command {} for item {}", commandAsString, item);
  Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandAsString);
  if (command == null) {
    logger.error("SNMP can't resolve command {} for item {}", commandAsString, item);

相关文章