// Autogenerated from Pigeon (v1.0.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package creativemaybeno.wakelock;

import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugin.common.StandardMessageCodec;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

/** Generated class from Pigeon. */
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
public class Messages {

  /** Generated class from Pigeon that represents data sent in messages. */
  public static class ToggleMessage {
    private Boolean enable;
    public Boolean getEnable() { return enable; }
    public void setEnable(Boolean setterArg) { this.enable = setterArg; }

    Map<String, Object> toMap() {
      Map<String, Object> toMapResult = new HashMap<>();
      toMapResult.put("enable", enable);
      return toMapResult;
    }
    static ToggleMessage fromMap(Map<String, Object> map) {
      ToggleMessage fromMapResult = new ToggleMessage();
      Object enable = map.get("enable");
      fromMapResult.enable = (Boolean)enable;
      return fromMapResult;
    }
  }

  /** Generated class from Pigeon that represents data sent in messages. */
  public static class IsEnabledMessage {
    private Boolean enabled;
    public Boolean getEnabled() { return enabled; }
    public void setEnabled(Boolean setterArg) { this.enabled = setterArg; }

    Map<String, Object> toMap() {
      Map<String, Object> toMapResult = new HashMap<>();
      toMapResult.put("enabled", enabled);
      return toMapResult;
    }
    static IsEnabledMessage fromMap(Map<String, Object> map) {
      IsEnabledMessage fromMapResult = new IsEnabledMessage();
      Object enabled = map.get("enabled");
      fromMapResult.enabled = (Boolean)enabled;
      return fromMapResult;
    }
  }
  private static class WakelockApiCodec extends StandardMessageCodec {
    public static final WakelockApiCodec INSTANCE = new WakelockApiCodec();
    private WakelockApiCodec() {}
    @Override
    protected Object readValueOfType(byte type, ByteBuffer buffer) {
      switch (type) {
        case (byte)128:         
          return IsEnabledMessage.fromMap((Map<String, Object>) readValue(buffer));
        
        case (byte)129:         
          return ToggleMessage.fromMap((Map<String, Object>) readValue(buffer));
        
        default:        
          return super.readValueOfType(type, buffer);
        
      }
    }
    @Override
    protected void writeValue(ByteArrayOutputStream stream, Object value)     {
      if (value instanceof IsEnabledMessage) {
        stream.write(128);
        writeValue(stream, ((IsEnabledMessage) value).toMap());
      } else 
      if (value instanceof ToggleMessage) {
        stream.write(129);
        writeValue(stream, ((ToggleMessage) value).toMap());
      } else 
{
        super.writeValue(stream, value);
      }
    }
  }

  /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/
  public interface WakelockApi {
    void toggle(ToggleMessage msg);
    IsEnabledMessage isEnabled();

    /** The codec used by WakelockApi. */
    static MessageCodec<Object> getCodec() {
      return WakelockApiCodec.INSTANCE;
    }

    /** Sets up an instance of `WakelockApi` to handle messages through the `binaryMessenger`. */
    static void setup(BinaryMessenger binaryMessenger, WakelockApi api) {
      {
        BasicMessageChannel<Object> channel =
            new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.toggle", getCodec());
        if (api != null) {
          channel.setMessageHandler((message, reply) -> {
            Map<String, Object> wrapped = new HashMap<>();
            try {
              ArrayList<Object> args = (ArrayList<Object>)message;
              ToggleMessage msgArg = (ToggleMessage)args.get(0);
              if (msgArg == null) {
                throw new NullPointerException("msgArg unexpectedly null.");
              }
              api.toggle(msgArg);
              wrapped.put("result", null);
            }
            catch (Error | RuntimeException exception) {
              wrapped.put("error", wrapError(exception));
            }
            reply.reply(wrapped);
          });
        } else {
          channel.setMessageHandler(null);
        }
      }
      {
        BasicMessageChannel<Object> channel =
            new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.isEnabled", getCodec());
        if (api != null) {
          channel.setMessageHandler((message, reply) -> {
            Map<String, Object> wrapped = new HashMap<>();
            try {
              IsEnabledMessage output = api.isEnabled();
              wrapped.put("result", output);
            }
            catch (Error | RuntimeException exception) {
              wrapped.put("error", wrapError(exception));
            }
            reply.reply(wrapped);
          });
        } else {
          channel.setMessageHandler(null);
        }
      }
    }
  }
  private static Map<String, Object> wrapError(Throwable exception) {
    Map<String, Object> errorMap = new HashMap<>();
    errorMap.put("message", exception.toString());
    errorMap.put("code", exception.getClass().getSimpleName());
    errorMap.put("details", null);
    return errorMap;
  }
}
