chromium/third_party/jni_zero/test/golden/testEndToEndProxyJniWithModules-SampleModuleJni.java.golden

//
// This file was generated by //third_party/jni_zero/jni_zero.py
//
package org.jni_zero;

import org.jni_zero.CheckDiscard;
import org.jni_zero.JniStaticTestMocker;
import org.jni_zero.NativeLibraryLoadedStatus;
import org.jni_zero.module_GEN_JNI;

@CheckDiscard("crbug.com/993421")
class SampleModuleJni implements SampleModule.Natives {
  private static SampleModule.Natives testInstance;

  public static final JniStaticTestMocker<SampleModule.Natives> TEST_HOOKS =
      new JniStaticTestMocker<SampleModule.Natives>() {
    @Override
    public void setInstanceForTesting(SampleModule.Natives instance) {
      if (!module_GEN_JNI.TESTING_ENABLED) {
        throw new RuntimeException(
            "Tried to set a JNI mock when mocks aren't enabled!");
      }
      testInstance = instance;
    }
  };

  @Override
  public boolean bar(boolean a) {
    return (boolean) module_GEN_JNI.org_jni_1zero_SampleModule_bar(a);
  }

  @Override
  public void foo() {
    module_GEN_JNI.org_jni_1zero_SampleModule_foo();
  }

  public static SampleModule.Natives get() {
    if (module_GEN_JNI.TESTING_ENABLED) {
      if (testInstance != null) {
        return testInstance;
      }
      if (module_GEN_JNI.REQUIRE_MOCK) {
        throw new UnsupportedOperationException(
            "No mock found for the native implementation of SampleModule.Natives. "
            + "The current configuration requires implementations be mocked.");
      }
    }
    NativeLibraryLoadedStatus.checkLoaded();
    return new SampleModuleJni();
  }
}