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

package io.sentry;

import java.util.concurrent.ConcurrentHashMap;
import io.sentry.vendor.gson.stream.JsonToken;
import java.io.IOException;
import java.util.Iterator;
import io.sentry.util.Objects;
import io.sentry.util.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import org.jetbrains.annotations.Nullable;

public final class SentryLockReason implements JsonUnknown, JsonSerializable
{
    public static final int LOCKED = 1;
    public static final int WAITING = 2;
    public static final int SLEEPING = 4;
    public static final int BLOCKED = 8;
    public static final int ANY = 15;
    private int type;
    @Nullable
    private String address;
    @Nullable
    private String packageName;
    @Nullable
    private String className;
    @Nullable
    private Long threadId;
    @Nullable
    private Map<String, Object> unknown;
    
    public SentryLockReason() {
    }
    
    public SentryLockReason(@NotNull final SentryLockReason other) {
        this.type = other.type;
        this.address = other.address;
        this.packageName = other.packageName;
        this.className = other.className;
        this.threadId = other.threadId;
        this.unknown = CollectionUtils.newConcurrentHashMap(other.unknown);
    }
    
    public int getType() {
        return this.type;
    }
    
    public void setType(final int type) {
        this.type = type;
    }
    
    @Nullable
    public String getAddress() {
        return this.address;
    }
    
    public void setAddress(@Nullable final String address) {
        this.address = address;
    }
    
    @Nullable
    public String getPackageName() {
        return this.packageName;
    }
    
    public void setPackageName(@Nullable final String packageName) {
        this.packageName = packageName;
    }
    
    @Nullable
    public String getClassName() {
        return this.className;
    }
    
    public void setClassName(@Nullable final String className) {
        this.className = className;
    }
    
    @Nullable
    public Long getThreadId() {
        return this.threadId;
    }
    
    public void setThreadId(@Nullable final Long threadId) {
        this.threadId = threadId;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final SentryLockReason that = (SentryLockReason)o;
        return Objects.equals(this.address, that.address);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.address);
    }
    
    @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();
        writer.name("type").value(this.type);
        if (this.address != null) {
            writer.name("address").value(this.address);
        }
        if (this.packageName != null) {
            writer.name("package_name").value(this.packageName);
        }
        if (this.className != null) {
            writer.name("class_name").value(this.className);
        }
        if (this.threadId != null) {
            writer.name("thread_id").value(this.threadId);
        }
        if (this.unknown != null) {
            for (final String key : this.unknown.keySet()) {
                final Object value = this.unknown.get(key);
                writer.name(key);
                writer.value(logger, value);
            }
        }
        writer.endObject();
    }
    
    public static final class JsonKeys
    {
        public static final String TYPE = "type";
        public static final String ADDRESS = "address";
        public static final String PACKAGE_NAME = "package_name";
        public static final String CLASS_NAME = "class_name";
        public static final String THREAD_ID = "thread_id";
    }
    
    public static final class Deserializer implements JsonDeserializer<SentryLockReason>
    {
        @NotNull
        @Override
        public SentryLockReason deserialize(@NotNull final ObjectReader reader, @NotNull final ILogger logger) throws Exception {
            final SentryLockReason sentryLockReason = new SentryLockReason();
            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": {
                        sentryLockReason.type = reader.nextInt();
                        continue;
                    }
                    case "address": {
                        sentryLockReason.address = reader.nextStringOrNull();
                        continue;
                    }
                    case "package_name": {
                        sentryLockReason.packageName = reader.nextStringOrNull();
                        continue;
                    }
                    case "class_name": {
                        sentryLockReason.className = reader.nextStringOrNull();
                        continue;
                    }
                    case "thread_id": {
                        sentryLockReason.threadId = reader.nextLongOrNull();
                        continue;
                    }
                    default: {
                        if (unknown == null) {
                            unknown = new ConcurrentHashMap<String, Object>();
                        }
                        reader.nextUnknown(logger, unknown, nextName);
                        continue;
                    }
                }
            }
            sentryLockReason.setUnknown(unknown);
            reader.endObject();
            return sentryLockReason;
        }
    }
}
