
/**
 * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be lost
 * once the code is regenerated.
 *
 * @generated by codegen project: GenerateModuleJavaSpec.js
 *
 * @nolint
 */

package com.escposprinter;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.build.ReactBuildConfig;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class NativeEscPosPrinterDiscoverySpec extends ReactContextBaseJavaModule{
  public static final String NAME = "EscPosPrinterDiscovery";

  public NativeEscPosPrinterDiscoverySpec(ReactApplicationContext reactContext) {
    super(reactContext);
  }

  @Override
  public @Nonnull String getName() {
    return NAME;
  }

  protected final void emitOnDiscovery(ReadableArray value) {
    mEventEmitterCallback.invoke("onDiscovery", value);
  }

  protected final void emitEnableLocationSettingSuccess() {
    mEventEmitterCallback.invoke("enableLocationSettingSuccess");
  }

  protected final void emitEnableLocationSettingFailure() {
    mEventEmitterCallback.invoke("enableLocationSettingFailure");
  }

  protected abstract Map<String, Object> getTypedExportedConstants();

  @Override
  @DoNotStrip
  public final @Nullable Map<String, Object> getConstants() {
    Map<String, Object> constants = getTypedExportedConstants();
    if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
      Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
          "BT_ERR_CANCEL",
          "BT_ERR_ILLEGAL_DEVICE",
          "BT_ERR_PARAM",
          "BT_ERR_UNSUPPORTED",
          "ERR_FAILURE",
          "ERR_ILLEGAL",
          "ERR_MEMORY",
          "ERR_PARAM",
          "ERR_PROCESSING",
          "FILTER_NAME",
          "FILTER_NONE",
          "MODEL_ALL",
          "PORTTYPE_ALL",
          "PORTTYPE_BLUETOOTH",
          "PORTTYPE_BLUETOOTH_LE",
          "PORTTYPE_TCP",
          "PORTTYPE_USB",
          "PRINTER_FALSE",
          "PRINTER_TRUE",
          "TYPE_ALL",
          "TYPE_DISPLAY",
          "TYPE_GFE",
          "TYPE_HYBRID_PRINTER",
          "TYPE_KEYBOARD",
          "TYPE_MSR",
          "TYPE_OTHER_PERIPHERAL",
          "TYPE_POS_KEYBOARD",
          "TYPE_PRINTER",
          "TYPE_SCANNER",
          "TYPE_SERIAL"
      ));
      Set<String> optionalFlowConstants = new HashSet<>();
      Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
      undeclaredConstants.removeAll(obligatoryFlowConstants);
      undeclaredConstants.removeAll(optionalFlowConstants);
      if (!undeclaredConstants.isEmpty()) {
        throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
      }
      undeclaredConstants = obligatoryFlowConstants;
      undeclaredConstants.removeAll(constants.keySet());
      if (!undeclaredConstants.isEmpty()) {
        throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
      }
    }
    return constants;
  }

  @ReactMethod
  @DoNotStrip
  public abstract void startDiscovery(ReadableMap filterOption, Promise promise);

  @ReactMethod
  @DoNotStrip
  public abstract void stopDiscovery(Promise promise);

  @ReactMethod
  @DoNotStrip
  public abstract void enableLocationSetting(Promise promise);

  @ReactMethod
  @DoNotStrip
  public abstract void pairBluetoothDevice(String macAddress, Promise promise);
}
