class Transformers {

   public static Optional<MessageBody> commandToMessageBody(Model m, boolean hubOffline, String command, Map<String, Object> params, boolean whitelisted, @Nullable ProductCatalogEntry pm) throws ErrorEventException {

      if(!Predicates.isSupportedModel(m, whitelisted, pm)) {
         if(m.supports(SceneCapability.NAMESPACE)) {
            throw new ErrorEventException(Constants.Error.NOT_SUPPORTED, "scene contains unsupprorted operations");
         }
         throw new ErrorEventException(Constants.Error.DEVICE_NOT_FOUND, "device doesn't exist or support google home");
      }

      if(Predicates.isDeviceOffline(m, hubOffline)) {
         throw new ErrorEventException(Constants.Error.DEVICE_OFFLINE, m.getId() + " is offline");
      }

      if(params == null) {
         params = ImmutableMap.of();
      }

      String platformCommand = Capability.CMD_SET_ATTRIBUTES;

      ImmutableMap.Builder<String, Object> attrBuilder = ImmutableMap.builder();
      switch(command) {
         case Commands.OnOff.name:
            addOnOffAttrs(m, attrBuilder, params);
            break;
         case Commands.BrightnessAbsolute.name:
            addBrightnessAttrs(m, attrBuilder, params);
            break;
         case Commands.ColorAbsolute.name:
            addColorAttrs(m, attrBuilder, params);
            break;
         case Commands.ActivateScene.name:
            if(!m.supports(SceneCapability.NAMESPACE)) {
               throw new ErrorEventException(Constants.Error.NOT_SUPPORTED, command + " is not supported");
            }
            platformCommand = SceneCapability.FireRequest.NAME;
            break;
         case Commands.SetThermostat.name:
            addThermostatAttrs(m, attrBuilder, params);
            break;
         default:
            throw new ErrorEventException(Constants.Error.NOT_SUPPORTED, command + " is not supported");
      }

      Map<String,Object> attrs = attrBuilder.build();
      if(Objects.equals(Capability.CMD_SET_ATTRIBUTES, platformCommand) && attrs.isEmpty()) {
         return Optional.empty();
      }

      return Optional.of(MessageBody.buildMessage(platformCommand, attrs));
   }

   private  Transformers();

}