/**
 * Copyright (c) 2017-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

package com.facebook.litho;

import android.support.v4.util.SimpleArrayMap;

/**
 * A class representing an event to log to a {@link ComponentsLogger}. There are two kind of events,
 * performance events and regular events. Performance events track the time between instantiation
 * and being logged while regular events do not. A {@link LogEvent} is created by requesting a new
 * event from the {@link ComponentsLogger} and they are recycled when logged and should not be
 * re-used.
 */
public final class LogEvent {
  private SimpleArrayMap<String, String> mParams = new SimpleArrayMap<>();
  private int mEventId = -1;
  private boolean mIsPerformanceEvent = false;

  LogEvent() {}

  void setEventId(int eventId) {
    mEventId = eventId;
  }

  void setIsPerformanceEvent(boolean performanceEvent) {
    mIsPerformanceEvent = performanceEvent;
  }

  void reset() {
    mParams.clear();
    mEventId = -1;
    mIsPerformanceEvent = false;
  }

  public int getEventId() {
    return mEventId;
  }

  public boolean isPerformanceEvent() {
    return mIsPerformanceEvent;
  }

  public void addParam(String key, String value) {
    mParams.put(key, value);
  }

  public int getParamCount() {
    return mParams.size();
  }

  public String getParamKeyAt(int index) {
    return mParams.keyAt(index);
  }

  public String getParamValueAt(int index) {
    return mParams.valueAt(index);
  }

  public String getParam(String paramMessage) {
    return mParams.get(paramMessage);
  }

  @Override
  public String toString() {
    return "eventId = " + mEventId +
        ", isPerformanceEvent = " + mIsPerformanceEvent +
        ", params = " + mParams.toString();
  }

  @Override
  public boolean equals(Object o) {
    if (o instanceof LogEvent) {
      final LogEvent other = (LogEvent) o;

      if (other.mEventId == mEventId && other.mIsPerformanceEvent == mIsPerformanceEvent) {
        for (int i = 0, count = mParams.size(); i < count; i++) {
          final String key = mParams.keyAt(i);

          if (other.mParams.containsKey(key)) {
            if (!mParams.get(key).equals(other.mParams.get(key))) {
              return false;
            }
          }
        }

        return true;
      }
    }

    return false;
  }
}

@@ -856,22 +856,22 @@
 String, 
-String
+Object
 %3E mParam
@@ -1421,22 +1421,22 @@
 ng key, 
-String
+Object
  value) 
@@ -1616,38 +1616,37 @@
 ;%0A  %7D%0A%0A  public 
-String
+%3CT%3E T
  getParamValueAt
@@ -1661,32 +1661,36 @@
 ex) %7B%0A    return
+ (T)
  mParams.valueAt
@@ -1704,38 +1704,37 @@
 ;%0A  %7D%0A%0A  public 
-String
+%3CT%3E T
  getParam(String
@@ -1752,32 +1752,36 @@
 ge) %7B%0A    return
+ (T)
  mParams.get(par

Allow non-string LogEvent params