public static boolean detectAutoRepeat(final Unit unit) { try { return unit.generateVariablePool().getValue("COMPANY").equalsIgnoreCase("philips"); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not detect auto repeat of "+unit+"!", ex, LOGGER, LogLevel.WARN); } return false; } }
/** * Returns the variable provider of this unit like {@code generateVariablePool()}. Additionally this provider also contains variables related to the given service of this unit. * For this it's needed that this unit supports the given service. Additional to the {@code generateVariablePool()} this method further provides: * * BindingServiceConfig (if available) * * ServiceMetaConfig (if available) * * ServiceConfig (protobuf fields) * * @return a key - value pair pool providing all related variable of this unit including the service variables. * * @throws NotAvailableException is thrown if the variable pool is not available e.g. because the unit is not compatible with the given service type.. */ default VariableProvider generateVariablePool(final ServiceType serviceType) throws NotAvailableException { for (ServiceConfig serviceConfig : getConfig().getServiceConfigList()) { if (serviceConfig.getServiceDescription().getType() == serviceType) { return generateVariablePool(serviceConfig); } } throw new NotAvailableException("VariableProvider", new InvalidStateException("ServiceType[" + serviceType.name() + "] not supported by " + this)); }
/** * Returns the variable provider of this unit like {@code generateVariablePool()}. Additionally this provider also contains variables related to the given service of this unit. * For this it's needed that this unit supports the given service. Additional to the {@code generateVariablePool()} this method further provides: * * BindingServiceConfig (if available) * * ServiceMetaConfig (if available) * * ServiceConfig (protobuf fields) * * @return a key - value pair pool providing all related variable of this unit including the service variables. * * @throws NotAvailableException is thrown if the variable pool is not available. */ default VariableProvider generateVariablePool(final ServiceConfig serviceConfig) throws NotAvailableException { final MetaConfigPool configPool = (MetaConfigPool) generateVariablePool(); if (serviceConfig.hasBindingConfig()) { configPool.register(new MetaConfigVariableProvider("BindingServiceConfig", serviceConfig.getBindingConfig().getMetaConfig())); } configPool.register(new MetaConfigVariableProvider("ServiceMetaConfig", serviceConfig.getMetaConfig())); configPool.register(new ProtobufVariableProvider(serviceConfig)); return configPool; }