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

package io.sentry.protocol;

import java.util.concurrent.ConcurrentHashMap;
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 io.sentry.ObjectWriter;
import io.sentry.util.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import io.sentry.JsonSerializable;
import io.sentry.JsonUnknown;

public final class SentryRuntime implements JsonUnknown, JsonSerializable
{
    public static final String TYPE = "runtime";
    @Nullable
    private String name;
    @Nullable
    private String version;
    @Nullable
    private String rawDescription;
    @Nullable
    private Map<String, Object> unknown;
    
    public SentryRuntime() {
    }
    
    SentryRuntime(@NotNull final SentryRuntime sentryRuntime) {
        this.name = sentryRuntime.name;
        this.version = sentryRuntime.version;
        this.rawDescription = sentryRuntime.rawDescription;
        this.unknown = CollectionUtils.newConcurrentHashMap(sentryRuntime.unknown);
    }
    
    @Nullable
    public String getName() {
        return this.name;
    }
    
    public void setName(@Nullable final String name) {
        this.name = name;
    }
    
    @Nullable
    public String getVersion() {
        return this.version;
    }
    
    public void setVersion(@Nullable final String version) {
        this.version = version;
    }
    
    @Nullable
    public String getRawDescription() {
        return this.rawDescription;
    }
    
    public void setRawDescription(@Nullable final String rawDescription) {
        this.rawDescription = rawDescription;
    }
    
    @Override
    public void serialize(@NotNull final ObjectWriter writer, @NotNull final ILogger logger) throws IOException {
        writer.beginObject();
        if (this.name != null) {
            writer.name("name").value(this.name);
        }
        if (this.version != null) {
            writer.name("version").value(this.version);
        }
        if (this.rawDescription != null) {
            writer.name("raw_description").value(this.rawDescription);
        }
        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();
    }
    
    @Nullable
    @Override
    public Map<String, Object> getUnknown() {
        return this.unknown;
    }
    
    @Override
    public void setUnknown(@Nullable final Map<String, Object> unknown) {
        this.unknown = unknown;
    }
    
    public static final class JsonKeys
    {
        public static final String NAME = "name";
        public static final String VERSION = "version";
        public static final String RAW_DESCRIPTION = "raw_description";
    }
    
    public static final class Deserializer implements JsonDeserializer<SentryRuntime>
    {
        @NotNull
        @Override
        public SentryRuntime deserialize(@NotNull final ObjectReader reader, @NotNull final ILogger logger) throws Exception {
            reader.beginObject();
            final SentryRuntime runtime = new SentryRuntime();
            Map<String, Object> unknown = null;
            while (reader.peek() == JsonToken.NAME) {
                final String nextName2;
                final String nextName = nextName2 = reader.nextName();
                switch (nextName2) {
                    case "name": {
                        runtime.name = reader.nextStringOrNull();
                        continue;
                    }
                    case "version": {
                        runtime.version = reader.nextStringOrNull();
                        continue;
                    }
                    case "raw_description": {
                        runtime.rawDescription = reader.nextStringOrNull();
                        continue;
                    }
                    default: {
                        if (unknown == null) {
                            unknown = new ConcurrentHashMap<String, Object>();
                        }
                        reader.nextUnknown(logger, unknown, nextName);
                        continue;
                    }
                }
            }
            runtime.setUnknown(unknown);
            reader.endObject();
            return runtime;
        }
    }
}
