// 
// Decompiled by Procyon v0.6.0
// 

package io.sentry.rrweb;

import io.sentry.JsonDeserializer;
import io.sentry.ObjectReader;
import java.io.IOException;
import io.sentry.ILogger;
import io.sentry.ObjectWriter;
import io.sentry.util.Objects;
import org.jetbrains.annotations.NotNull;

public abstract class RRWebEvent
{
    @NotNull
    private RRWebEventType type;
    private long timestamp;
    
    protected RRWebEvent(@NotNull final RRWebEventType type) {
        this.type = type;
        this.timestamp = System.currentTimeMillis();
    }
    
    protected RRWebEvent() {
        this(RRWebEventType.Custom);
    }
    
    @NotNull
    public RRWebEventType getType() {
        return this.type;
    }
    
    public void setType(@NotNull final RRWebEventType type) {
        this.type = type;
    }
    
    public long getTimestamp() {
        return this.timestamp;
    }
    
    public void setTimestamp(final long timestamp) {
        this.timestamp = timestamp;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RRWebEvent)) {
            return false;
        }
        final RRWebEvent that = (RRWebEvent)o;
        return this.timestamp == that.timestamp && this.type == that.type;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.type, this.timestamp);
    }
    
    public static final class JsonKeys
    {
        public static final String TYPE = "type";
        public static final String TIMESTAMP = "timestamp";
        public static final String TAG = "tag";
    }
    
    public static final class Serializer
    {
        public void serialize(@NotNull final RRWebEvent baseEvent, @NotNull final ObjectWriter writer, @NotNull final ILogger logger) throws IOException {
            writer.name("type").value(logger, baseEvent.type);
            writer.name("timestamp").value(baseEvent.timestamp);
        }
    }
    
    public static final class Deserializer
    {
        public boolean deserializeValue(@NotNull final RRWebEvent baseEvent, @NotNull final String nextName, @NotNull final ObjectReader reader, @NotNull final ILogger logger) throws Exception {
            switch (nextName) {
                case "type": {
                    baseEvent.type = Objects.requireNonNull((RRWebEventType)reader.nextOrNull(logger, (JsonDeserializer<T>)new RRWebEventType.Deserializer()), "");
                    return true;
                }
                case "timestamp": {
                    baseEvent.timestamp = reader.nextLong();
                    return true;
                }
                default: {
                    return false;
                }
            }
        }
    }
}
