use of org.openhab.binding.zwave.internal.converter.state.StateComparator in project openhab1-addons by openhab.
the class ZWaveConverterBase method getStateConverter.
/**
* Gets a {@link ZWaveStateConverter} that is suitable for this {@link CommandClass} and the data types supported by
* the {@link Item}
*
* @param commandClass the {@link CommandClass} that sent the value.
* @param item the {@link Item} that has to receive the State;
* @return a converter object that converts between the value and the state;
*/
protected ZWaveStateConverter<?, ?> getStateConverter(Item item, Object value) {
if (item == null) {
return null;
}
List<Class<? extends State>> list = new ArrayList<Class<? extends State>>(item.getAcceptedDataTypes());
Collections.sort(list, new StateComparator());
for (Class<? extends State> stateClass : list) {
ZWaveStateConverter<?, ?> result = stateConverters.get(stateClass);
if (result == null || !result.getType().isInstance(value)) {
continue;
}
return result;
}
return null;
}
Aggregations