package com.l7tech.gateway.common.service;

import com.l7tech.objectmodel.Goid;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;

public class ServiceStatistics implements Serializable {
   private Goid _serviceGoid = PublishedService.DEFAULT_GOID;
   private String _serviceName = "";
   private final AtomicLong _attemptedRequestCount = new AtomicLong(0L);
   private final AtomicLong _authorizedRequestCount = new AtomicLong(0L);
   private final AtomicLong _completedRequestCount = new AtomicLong(0L);
   static final long serialVersionUID = -7671837628865970414L;

   public ServiceStatistics(Goid var1) {
      this._serviceGoid = var1;
   }

   public ServiceStatistics(Goid var1, long var2, long var4, long var6) {
      this._serviceGoid = var1;
      this.resetNegativeServiceStatisticsCounters(var2, var4, var6);
   }

   private void resetNegativeServiceStatisticsCounters(long var1, long var3, long var5) {
      if (var5 < 0L) {
         var5 = 2147483647L;
         var3 = 2147483647L;
         var1 = 2147483647L;
      } else if (var3 < 0L) {
         var3 = 2147483647L;
         var1 = 2147483647L;
      } else if (var1 < 0L) {
         var1 = 2147483647L;
      }

      this._attemptedRequestCount.set(var1);
      this._authorizedRequestCount.set(var3);
      this._completedRequestCount.set(var5);
   }

   public Goid getServiceGoid() {
      return this._serviceGoid;
   }

   public String getServiceName() {
      return this._serviceName;
   }

   public void setServiceName(String var1) {
      this._serviceName = var1;
   }

   public long getAttemptedRequestCount() {
      return this._attemptedRequestCount.get();
   }

   public void attemptedRequest() {
      this._attemptedRequestCount.incrementAndGet();
   }

   public long getAuthorizedRequestCount() {
      return this._authorizedRequestCount.get();
   }

   public void authorizedRequest() {
      this._authorizedRequestCount.incrementAndGet();
   }

   public long getCompletedRequestCount() {
      return this._completedRequestCount.get();
   }

   public void completedRequest() {
      this._completedRequestCount.incrementAndGet();
   }

   @Override
   public boolean equals(Object var1) {
      if (this == var1) {
         return true;
      } else if (!(var1 instanceof ServiceStatistics var2)) {
         return false;
      } else if (this._attemptedRequestCount.get() != var2._attemptedRequestCount.get()) {
         return false;
      } else if (this._authorizedRequestCount.get() != var2._authorizedRequestCount.get()) {
         return false;
      } else {
         return this._completedRequestCount.get() != var2._completedRequestCount.get() ? false : Goid.equals(this._serviceGoid, var2._serviceGoid);
      }
   }

   @Override
   public int hashCode() {
      int var1 = this._serviceGoid != null ? this._serviceGoid.hashCode() : 0;
      var1 = 29 * var1 + (int)this._attemptedRequestCount.get();
      var1 = 29 * var1 + (int)this._authorizedRequestCount.get();
      return 29 * var1 + (int)this._completedRequestCount.get();
   }
}
