package com.google.common.eventbus;

import com.google.common.base.Preconditions;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.annotation.Nullable;

class EventSubscriber {
   private final Object target;
   private final Method method;

   EventSubscriber(Object target, Method method) {
      Preconditions.checkNotNull(target, "EventSubscriber target cannot be null.");
      Preconditions.checkNotNull(method, "EventSubscriber method cannot be null.");
      this.target = target;
      this.method = method;
      method.setAccessible(true);
   }

   public void handleEvent(Object event) throws InvocationTargetException {
      Preconditions.checkNotNull(event);

      String var3;
      try {
         this.method.invoke(this.target, event);
      } catch (IllegalArgumentException var4) {
         var3 = String.valueOf(String.valueOf(event));
         throw new Error((new StringBuilder(33 + var3.length())).append("Method rejected target/argument: ").append(var3).toString(), var4);
      } catch (IllegalAccessException var5) {
         var3 = String.valueOf(String.valueOf(event));
         throw new Error((new StringBuilder(28 + var3.length())).append("Method became inaccessible: ").append(var3).toString(), var5);
      } catch (InvocationTargetException var6) {
         if (var6.getCause() instanceof Error) {
            throw (Error)var6.getCause();
         } else {
            throw var6;
         }
      }
   }

   public String toString() {
      String var1 = String.valueOf(String.valueOf(this.method));
      return (new StringBuilder(10 + var1.length())).append("[wrapper ").append(var1).append("]").toString();
   }

   public int hashCode() {
      int PRIME = true;
      return (31 + this.method.hashCode()) * 31 + System.identityHashCode(this.target);
   }

   public boolean equals(@Nullable Object obj) {
      if (!(obj instanceof EventSubscriber)) {
         return false;
      } else {
         EventSubscriber that = (EventSubscriber)obj;
         return this.target == that.target && this.method.equals(that.method);
      }
   }

   public Object getSubscriber() {
      return this.target;
   }

   public Method getMethod() {
      return this.method;
   }
}
