AnalyticsEventBuilder.java 4.83 KB
package com.bitstrips.imoji.analytics;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.bitstrips.imoji.experiments.Experiments;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.json.JSONObject;

public class AnalyticsEventBuilder
{
  private final Category a;
  private Long b;
  private Action c;
  private String d;
  private Long e;
  private AnalyticsWrapper f;
  private final Experiments g;
  
  public AnalyticsEventBuilder(@NonNull Category paramCategory, @NonNull Action paramAction, @NonNull Experiments paramExperiments)
  {
    this.a = paramCategory;
    this.c = paramAction;
    this.b = Long.valueOf(System.currentTimeMillis());
    this.g = paramExperiments;
  }
  
  public AnalyticsEvent build()
  {
    if ((this.f != null) && (this.d != null)) {
      throw new IllegalArgumentException("analtyics wrapper and label can't both be present");
    }
    if ((this.d == null) && (this.e != null)) {
      throw new IllegalArgumentException("must have label if value is present");
    }
    AnalyticsEvent localAnalyticsEvent = new AnalyticsEvent(this.a, this.c, this.b, (byte)0);
    if (this.f != null) {
      localAnalyticsEvent.setLabel(new JSONObject(this.f.buildMap()).toString());
    }
    for (;;)
    {
      if (this.e != null) {
        localAnalyticsEvent.setValue(this.e);
      }
      localAnalyticsEvent.setExperimentIds(this.g.getExperimentIds());
      return localAnalyticsEvent;
      if (this.d != null) {
        localAnalyticsEvent.setLabel(this.d);
      }
    }
  }
  
  public AnalyticsEventBuilder withAnalyticsWrapper(@NonNull AnalyticsWrapper paramAnalyticsWrapper)
  {
    this.f = paramAnalyticsWrapper;
    return this;
  }
  
  public AnalyticsEventBuilder withLabel(@NonNull String paramString)
  {
    this.d = paramString;
    return this;
  }
  
  public AnalyticsEventBuilder withValue(@NonNull Long paramLong)
  {
    this.e = paramLong;
    return this;
  }
  
  public class AnalyticsEvent
    implements Serializable
  {
    @SerializedName("category")
    Category a;
    @SerializedName("action")
    Action b;
    @SerializedName("avatarId")
    String c;
    @SerializedName("timestamp")
    Long d;
    @SerializedName("label")
    String e;
    @SerializedName("value")
    Long f;
    @SerializedName("appId")
    Integer g;
    @SerializedName("has_snapchat_installed")
    Boolean h;
    @SerializedName("session_id")
    String i;
    @SerializedName("experimentIds")
    int[] j;
    @SerializedName("sequence_id")
    int k;
    @SerializedName("retry_count")
    int l;
    
    private AnalyticsEvent(@NonNull Category paramCategory, @NonNull Action paramAction, @NonNull Long paramLong)
    {
      this.a = paramCategory;
      this.b = paramAction;
      this.d = paramLong;
      this.l = -1;
    }
    
    public boolean equals(Object paramObject)
    {
      if (!(paramObject instanceof AnalyticsEvent)) {
        return false;
      }
      paramObject = (AnalyticsEvent)paramObject;
      return new EqualsBuilder().append(this.k, ((AnalyticsEvent)paramObject).k).append(this.i, ((AnalyticsEvent)paramObject).i).append(this.c, ((AnalyticsEvent)paramObject).c).append(this.d, ((AnalyticsEvent)paramObject).d).build().booleanValue();
    }
    
    public Category getCategory()
    {
      return this.a;
    }
    
    public int getRetryCount()
    {
      return this.l;
    }
    
    public boolean hasBeenLogged()
    {
      return this.l != -1;
    }
    
    public int hashCode()
    {
      int i1 = this.k;
      int n = i1;
      if (this.i != null) {
        n = i1 + this.i.hashCode();
      }
      return n;
    }
    
    public void incrementRetryCount()
    {
      this.l += 1;
    }
    
    public void setAppId(@NonNull Integer paramInteger)
    {
      this.g = paramInteger;
    }
    
    public void setAvatarId(@Nullable String paramString)
    {
      this.c = paramString;
    }
    
    public void setExperimentIds(int[] paramArrayOfInt)
    {
      this.j = ((int[])paramArrayOfInt.clone());
    }
    
    public void setHasSnapchatInstalled(boolean paramBoolean)
    {
      this.h = Boolean.valueOf(paramBoolean);
    }
    
    public void setLabel(@NonNull String paramString)
    {
      this.e = paramString;
    }
    
    public void setSequenceId(int paramInt)
    {
      this.k = paramInt;
    }
    
    public void setSessionId(String paramString)
    {
      this.i = paramString;
    }
    
    public void setValue(@Nullable Long paramLong)
    {
      this.f = paramLong;
    }
    
    public String toString()
    {
      return super.toString();
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/analytics/AnalyticsEventBuilder.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */