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

package io.sentry.protocol;

import java.util.HashMap;
import io.sentry.vendor.gson.stream.JsonToken;
import io.sentry.ObjectReader;
import io.sentry.JsonDeserializer;
import java.io.IOException;
import java.util.Iterator;
import io.sentry.ILogger;
import org.jetbrains.annotations.NotNull;
import io.sentry.ObjectWriter;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import io.sentry.JsonSerializable;
import io.sentry.JsonUnknown;

public final class SentryException implements JsonUnknown, JsonSerializable
{
    @Nullable
    private String type;
    @Nullable
    private String value;
    @Nullable
    private String module;
    @Nullable
    private Long threadId;
    @Nullable
    private SentryStackTrace stacktrace;
    @Nullable
    private Mechanism mechanism;
    @Nullable
    private Map<String, Object> unknown;
    
    @Nullable
    public String getType() {
        return this.type;
    }
    
    public void setType(@Nullable final String type) {
        this.type = type;
    }
    
    @Nullable
    public String getValue() {
        return this.value;
    }
    
    public void setValue(@Nullable final String value) {
        this.value = value;
    }
    
    @Nullable
    public String getModule() {
        return this.module;
    }
    
    public void setModule(@Nullable final String module) {
        this.module = module;
    }
    
    @Nullable
    public Long getThreadId() {
        return this.threadId;
    }
    
    public void setThreadId(@Nullable final Long threadId) {
        this.threadId = threadId;
    }
    
    @Nullable
    public SentryStackTrace getStacktrace() {
        return this.stacktrace;
    }
    
    public void setStacktrace(@Nullable final SentryStackTrace stacktrace) {
        this.stacktrace = stacktrace;
    }
    
    @Nullable
    public Mechanism getMechanism() {
        return this.mechanism;
    }
    
    public void setMechanism(@Nullable final Mechanism mechanism) {
        this.mechanism = mechanism;
    }
    
    @Nullable
    @Override
    public Map<String, Object> getUnknown() {
        return this.unknown;
    }
    
    @Override
    public void setUnknown(@Nullable final Map<String, Object> unknown) {
        this.unknown = unknown;
    }
    
    @Override
    public void serialize(@NotNull final ObjectWriter writer, @NotNull final ILogger logger) throws IOException {
        writer.beginObject();
        if (this.type != null) {
            writer.name("type").value(this.type);
        }
        if (this.value != null) {
            writer.name("value").value(this.value);
        }
        if (this.module != null) {
            writer.name("module").value(this.module);
        }
        if (this.threadId != null) {
            writer.name("thread_id").value(this.threadId);
        }
        if (this.stacktrace != null) {
            writer.name("stacktrace").value(logger, this.stacktrace);
        }
        if (this.mechanism != null) {
            writer.name("mechanism").value(logger, this.mechanism);
        }
        if (this.unknown != null) {
            for (final String key : this.unknown.keySet()) {
                final Object value = this.unknown.get(key);
                writer.name(key).value(logger, value);
            }
        }
        writer.endObject();
    }
    
    public static final class JsonKeys
    {
        public static final String TYPE = "type";
        public static final String VALUE = "value";
        public static final String MODULE = "module";
        public static final String THREAD_ID = "thread_id";
        public static final String STACKTRACE = "stacktrace";
        public static final String MECHANISM = "mechanism";
    }
    
    public static final class Deserializer implements JsonDeserializer<SentryException>
    {
        @NotNull
        @Override
        public SentryException deserialize(@NotNull final ObjectReader reader, @NotNull final ILogger logger) throws Exception {
            final SentryException sentryException = new SentryException();
            Map<String, Object> unknown = null;
            reader.beginObject();
            while (reader.peek() == JsonToken.NAME) {
                final String nextName2;
                final String nextName = nextName2 = reader.nextName();
                switch (nextName2) {
                    case "type": {
                        sentryException.type = reader.nextStringOrNull();
                        continue;
                    }
                    case "value": {
                        sentryException.value = reader.nextStringOrNull();
                        continue;
                    }
                    case "module": {
                        sentryException.module = reader.nextStringOrNull();
                        continue;
                    }
                    case "thread_id": {
                        sentryException.threadId = reader.nextLongOrNull();
                        continue;
                    }
                    case "stacktrace": {
                        sentryException.stacktrace = reader.nextOrNull(logger, (JsonDeserializer<SentryStackTrace>)new SentryStackTrace.Deserializer());
                        continue;
                    }
                    case "mechanism": {
                        sentryException.mechanism = reader.nextOrNull(logger, (JsonDeserializer<Mechanism>)new Mechanism.Deserializer());
                        continue;
                    }
                    default: {
                        if (unknown == null) {
                            unknown = new HashMap<String, Object>();
                        }
                        reader.nextUnknown(logger, unknown, nextName);
                        continue;
                    }
                }
            }
            reader.endObject();
            sentryException.setUnknown(unknown);
            return sentryException;
        }
    }
}
