package com.l7tech.server.audit;

import com.l7tech.util.Functions.Nullary;

public class AuditContextUtils {
   private static final ThreadLocal<Boolean> a = new an();
   private static final ThreadLocal<AuditsCollector> b = new ao();

   public static boolean isSystem() {
      return a.get();
   }

   public static void setSystem(boolean var0) {
      a.set(var0);
   }

   public static void doAsSystem(Runnable var0) {
      boolean var1 = isSystem();

      try {
         setSystem(true);
         var0.run();
      } finally {
         setSystem(var1);
      }
   }

   public static AuditsCollector getAuditsCollector() {
      return b.get();
   }

   public static <T> T doWithAuditsCollector(AuditsCollector var0, Nullary<T> var1) {
      AuditsCollector var2 = b.get();
      b.set(var0);

      try {
         return (T)var1.call();
      } finally {
         b.set(var2);
      }
   }
}
