当前位置: 首页>>代码示例>>Java>>正文


Java ContactItem类代码示例

本文整理汇总了Java中org.eclipse.smarthome.core.library.items.ContactItem的典型用法代码示例。如果您正苦于以下问题:Java ContactItem类的具体用法?Java ContactItem怎么用?Java ContactItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContactItem类属于org.eclipse.smarthome.core.library.items包,在下文中一共展示了ContactItem类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapToOpenHABItem

import org.eclipse.smarthome.core.library.items.ContactItem; //导入依赖的package包/类
public static org.openhab.core.items.Item mapToOpenHABItem(Item item) {
	org.openhab.core.items.Item result = null;
	if(item instanceof StringItem) result = new org.openhab.core.library.items.StringItem(item.getName());
	if(item instanceof SwitchItem) result = new org.openhab.core.library.items.SwitchItem(item.getName());
	if(item instanceof ContactItem) result = new org.openhab.core.library.items.ContactItem(item.getName());
	if(item instanceof NumberItem) result = new org.openhab.core.library.items.NumberItem(item.getName());
	if(item instanceof RollershutterItem) result = new org.openhab.core.library.items.RollershutterItem(item.getName());
	if(item instanceof DimmerItem) result = new org.openhab.core.library.items.DimmerItem(item.getName());
	if(item instanceof ColorItem) result = new org.openhab.core.library.items.ColorItem(item.getName());
	if(item instanceof DateTimeItem) result = new org.openhab.core.library.items.DateTimeItem(item.getName());
	if(item instanceof ESHCallItem) result = new org.openhab.library.tel.items.CallItem(item.getName());

    if(item instanceof GroupItem) {
           GroupItem gItem = (GroupItem) item;
           org.openhab.core.items.Item baseItem = ItemMapper.mapToOpenHABItem(gItem.getBaseItem());
           org.openhab.core.items.GroupItem ohgItem;
           if(baseItem instanceof GenericItem) {
               ohgItem = new org.openhab.core.items.GroupItem(item.getName(), (GenericItem) baseItem);
           } else {
               ohgItem = new org.openhab.core.items.GroupItem(item.getName());
           }
           for(Item member : gItem.getMembers()) {
               org.openhab.core.items.Item ohMember = ItemMapper.mapToOpenHABItem(member);
               if(ohMember != null) {
                   ohgItem.addMember(ohMember);
               }
           }
           result = ohgItem;
    }
    
	if(result instanceof org.openhab.core.items.GenericItem) {
		org.openhab.core.items.GenericItem genericItem = (GenericItem) result;
		if(item.getState()!=null) {
			genericItem.setState(TypeParser.parseState(genericItem.getAcceptedDataTypes(), item.getState().toString()));
		}
	}
	return result;
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:39,代码来源:ItemMapper.java


注:本文中的org.eclipse.smarthome.core.library.items.ContactItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。