use of org.eclipse.smarthome.core.thing.binding.firmware.Firmware in project smarthome by eclipse.
the class FirmwareRegistry method getFirmware.
/**
* Returns the firmware for the given UID.
*
* @param firmwareUID the firmware UID (must not be null)
* @param locale the locale to be used (if null then the locale provided by the {@link LocaleProvider} is used)
* @return the corresponding firmware or null if no firmware was found
* @throws NullPointerException if given firmware UID is null
*/
public Firmware getFirmware(FirmwareUID firmwareUID, Locale locale) {
Objects.requireNonNull(firmwareUID, "Firmware UID must not be null.");
Locale loc = locale != null ? locale : localeProvider.getLocale();
for (FirmwareProvider firmwareProvider : firmwareProviders) {
try {
Firmware firmware = firmwareProvider.getFirmware(firmwareUID, loc);
if (firmware != null) {
return firmware;
}
} catch (Exception e) {
logger.warn("Unexpected exception occurred for firmware provider {} while getting firmware for firmware UID {}.", firmwareProvider.getClass().getSimpleName(), firmwareUID, e);
}
}
return null;
}
use of org.eclipse.smarthome.core.thing.binding.firmware.Firmware in project smarthome by eclipse.
the class FirmwareRegistry method getFirmwares.
/**
* Returns the collection of available firmwares for the given thing type UID and locale. The collection is
* sorted in descending order, i.e. the latest firmware will be the first element in the collection.
*
* @param thingTypeUID the thing type UID for which the firmwares are to be provided (not null)
* @param locale the locale to be used (if null then the locale provided by the {@link LocaleProvider} is used)
* @return the collection of available firmwares for the given thing type UID (not null)
* @throws NullPointerException if given thing type UID is null
*/
public Collection<Firmware> getFirmwares(ThingTypeUID thingTypeUID, Locale locale) {
Objects.requireNonNull(thingTypeUID, "Thing type UID must not be null.");
Locale loc = locale != null ? locale : localeProvider.getLocale();
Set<Firmware> firmwares = new TreeSet<>();
for (FirmwareProvider firmwareProvider : firmwareProviders) {
try {
Collection<Firmware> result = firmwareProvider.getFirmwares(thingTypeUID, loc);
if (result != null) {
firmwares.addAll(result);
}
} catch (Exception e) {
logger.warn("Unexpected exception occurred for firmware provider {} while getting firmwares for thing type UID {}.", firmwareProvider.getClass().getSimpleName(), thingTypeUID, e);
}
}
return Collections.unmodifiableCollection(firmwares);
}
Aggregations