當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。