Search in sources :

Example 1 with ItemIterator

use of org.openhab.binding.astro.internal.util.ItemIterator in project openhab1-addons by openhab.

the class PlanetPublisher method publish.

/**
     * Iterates through all items and publishes the states.
     */
public void publish(final PlanetName planetName) {
    final Planet planet = context.getPlanet(planetName);
    new ItemIterator().iterate(new ItemIteratorCallback() {

        @Override
        public void next(AstroBindingConfig bindingConfig, Item item) {
            if (planetName == bindingConfig.getPlanetName()) {
                try {
                    Object value = PropertyUtils.getPropertyValue(planet, bindingConfig.getPlanetProperty());
                    if (!equalsCachedValue(value, item)) {
                        publishValue(item, value, bindingConfig);
                        itemCache.put(item.getName(), value);
                    }
                } catch (Exception ex) {
                    logger.warn(ex.getMessage(), ex);
                }
            }
        }
    });
}
Also used : Item(org.openhab.core.items.Item) ItemIteratorCallback(org.openhab.binding.astro.internal.util.ItemIterator.ItemIteratorCallback) Planet(org.openhab.binding.astro.internal.model.Planet) AstroBindingConfig(org.openhab.binding.astro.internal.config.AstroBindingConfig) ItemIterator(org.openhab.binding.astro.internal.util.ItemIterator)

Aggregations

AstroBindingConfig (org.openhab.binding.astro.internal.config.AstroBindingConfig)1 Planet (org.openhab.binding.astro.internal.model.Planet)1 ItemIterator (org.openhab.binding.astro.internal.util.ItemIterator)1 ItemIteratorCallback (org.openhab.binding.astro.internal.util.ItemIterator.ItemIteratorCallback)1 Item (org.openhab.core.items.Item)1