package com.twitter.util;

import java.util.function.Supplier;

import scala.PartialFunction;
import scala.runtime.BoxedUnit;

import static com.twitter.util.Function.func0;

/**
 * Java friendly APIs for the com.twitter.util.Monitor companion
 * object.
 */
public final class Monitors {
  private Monitors() { }

  private static final Monitor$ it =
      Monitor$.MODULE$;

  /**
   * The singleton `Monitor` instance that is the Monitor companion object.
   */
  public static Monitor instance() {
    return it;
  }

  /**
   * Equivalent to calling `Monitor.get`.
   */
  public static Monitor get() {
    return it.get();
  }

  /**
   * Equivalent to calling `Monitor.set`.
   */
  public static void set(Monitor monitor) {
    it.set(monitor);
  }

  /**
   * Equivalent to calling `Monitor.using`.
   */
  public static <T> T using(Monitor monitor, Supplier<T> supplier) {
    return it.using(monitor, func0(supplier));
  }

  /**
   * Equivalent to calling `Monitor.restoring`.
   */
  public static <T> T restoring(Supplier<T> supplier) {
    return it.restoring(func0(supplier));
  }

  /**
   * Equivalent to `Monitor.catcher`.
   */
  public static PartialFunction<Throwable, BoxedUnit> catcher() {
    return it.catcher();
  }

  /**
   * Equivalent to calling `Monitor.isActive`.
   */
  public static boolean isActive() {
    return it.isActive();
  }

}

@@ -312,76 +312,14 @@
  %7D%0A%0A
-  private static final Monitor$ it =%0A      Monitor$.MODULE$;%0A%0A
   /**%0A
+
    *
@@ -444,18 +444,32 @@
  return 
-it
+Monitor$.MODULE$
 ;%0A  %7D%0A%0A 
@@ -564,18 +564,32 @@
  return 
-it
+Monitor$.MODULE$
 .get();%0A
@@ -695,18 +695,32 @@
 ) %7B%0A    
-it
+Monitor$.MODULE$
 .set(mon
@@ -867,18 +867,32 @@
  return 
-it
+Monitor$.MODULE$
 .using(m
@@ -1049,18 +1049,32 @@
  return 
-it
+Monitor$.MODULE$
 .restori
@@ -1226,18 +1226,32 @@
  return 
-it
+Monitor$.MODULE$
 .catcher
@@ -1366,18 +1366,32 @@
  return 
-it
+Monitor$.MODULE$
 .isActiv

Rework Monitors Internals for Unidoc Generation