本文整理汇总了Java中com.connectsdk.service.capability.CapabilityMethods.CapabilityPriorityLevel.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java CapabilityPriorityLevel.getValue方法的具体用法?Java CapabilityPriorityLevel.getValue怎么用?Java CapabilityPriorityLevel.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.connectsdk.service.capability.CapabilityMethods.CapabilityPriorityLevel
的用法示例。
在下文中一共展示了CapabilityPriorityLevel.getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCapability
import com.connectsdk.service.capability.CapabilityMethods.CapabilityPriorityLevel; //导入方法依赖的package包/类
/**
* Get a capability with the highest priority from a device. If device doesn't have such
* capability then returns null.
* @param controllerClass type of capability
* @return capability implementation
*/
public <T extends CapabilityMethods> T getCapability(Class<T> controllerClass) {
T foundController = null;
CapabilityPriorityLevel foundControllerPriority = CapabilityPriorityLevel.NOT_SUPPORTED;
for (DeviceService service: services.values()) {
if (service.getAPI(controllerClass) == null)
continue;
T controller = service.getAPI(controllerClass);
CapabilityPriorityLevel controllerPriority = service.getPriorityLevel(controllerClass);
if (foundController == null) {
foundController = controller;
if (controllerPriority == null || controllerPriority == CapabilityPriorityLevel.NOT_SUPPORTED) {
Log.w(Util.T, "We found a mathcing capability class, but no priority level for the class. Please check \"getPriorityLevel()\" in your class");
}
foundControllerPriority = controllerPriority;
}
else if (controllerPriority != null && foundControllerPriority != null) {
if (controllerPriority.getValue() > foundControllerPriority.getValue()) {
foundController = controller;
foundControllerPriority = controllerPriority;
}
}
}
return foundController;
}