class Transformers {

   public static Map<String,Object> modelToStateMap(Model m, boolean hubOffline, boolean whitelisted, @Nullable ProductCatalogEntry pm) {
      if(!Predicates.isSupportedModel(m, whitelisted, pm)) {
         return ImmutableMap.of(Constants.States.ERROR_CODE, Constants.Error.DEVICE_NOT_FOUND);
      }

      ImmutableMap.Builder<String,Object> builder = ImmutableMap.builder();
      builder.put(Constants.States.ONLINE, !Predicates.isDeviceOffline(m, hubOffline));
      if(m.supports(SwitchCapability.NAMESPACE)) {
         builder.put(Constants.States.OnOff.ON, Objects.equals(SwitchCapability.STATE_ON, SwitchModel.getState(m, SwitchCapability.STATE_OFF)));
      }
      if(m.supports(DimmerCapability.NAMESPACE)) {
         builder.put(Constants.States.Brightness.BRIGHTNESS, DimmerModel.getBrightness(m));
      }
      if(m.supports(ColorCapability.NAMESPACE) || m.supports(ColorTemperatureCapability.NAMESPACE)) {
         modelToColor(m).ifPresent((c) -> builder.put(Constants.States.Color.COLOR, c.toMap()));
      }
      if(m.supports(ThermostatCapability.NAMESPACE)) {
         String mode = ThermostatModel.getHvacmode(m);
         builder.put(Constants.States.TemperatureSetting.MODE, Constants.TemperatureSettingMode.fromIris(mode).name());
         builder.put(Constants.States.TemperatureSetting.TEMPERATURE_AMBIENT, TemperatureModel.getTemperature(m));
         switch(mode) {
            case ThermostatCapability.HVACMODE_AUTO:
               builder.put(Constants.States.TemperatureSetting.TEMPERATURE_SET_LOW, ThermostatModel.getHeatsetpoint(m));
               builder.put(Constants.States.TemperatureSetting.TEMPERATURE_SET_HIGH, ThermostatModel.getCoolsetpoint(m));
               break;
            case ThermostatCapability.HVACMODE_COOL:
               builder.put(Constants.States.TemperatureSetting.TEMPERATURE_SET, ThermostatModel.getCoolsetpoint(m));
               break;
            case ThermostatCapability.HVACMODE_HEAT:
               builder.put(Constants.States.TemperatureSetting.TEMPERATURE_SET, ThermostatModel.getHeatsetpoint(m));
               break;
            default: /* no op */
         }
      }
      if(m.supports(RelativeHumidityCapability.NAMESPACE)) {
         builder.put(Constants.States.TemperatureSetting.HUMIDITY_AMBIENT, RelativeHumidityModel.getHumidity(m));
      }

      return builder.build();
   }

   private  Transformers();

}