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

package io.sentry;

import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import java.util.Map;

public final class SentryAttributes
{
    @NotNull
    private final Map<String, SentryAttribute> attributes;
    
    private SentryAttributes(@NotNull final Map<String, SentryAttribute> attributes) {
        this.attributes = attributes;
    }
    
    public void add(@Nullable final SentryAttribute attribute) {
        if (attribute == null) {
            return;
        }
        this.attributes.put(attribute.getName(), attribute);
    }
    
    @NotNull
    public Map<String, SentryAttribute> getAttributes() {
        return this.attributes;
    }
    
    @NotNull
    public static SentryAttributes of(@Nullable final SentryAttribute... attributes) {
        if (attributes == null) {
            return new SentryAttributes(new ConcurrentHashMap<String, SentryAttribute>());
        }
        final SentryAttributes sentryAttributes = new SentryAttributes(new ConcurrentHashMap<String, SentryAttribute>(attributes.length));
        for (final SentryAttribute attribute : attributes) {
            sentryAttributes.add(attribute);
        }
        return sentryAttributes;
    }
    
    @NotNull
    public static SentryAttributes fromMap(@Nullable final Map<String, Object> attributes) {
        if (attributes == null) {
            return new SentryAttributes(new ConcurrentHashMap<String, SentryAttribute>());
        }
        final SentryAttributes sentryAttributes = new SentryAttributes(new ConcurrentHashMap<String, SentryAttribute>(attributes.size()));
        for (final Map.Entry<String, Object> attribute : attributes.entrySet()) {
            final String key = attribute.getKey();
            if (key != null) {
                sentryAttributes.add(SentryAttribute.named(key, attribute.getValue()));
            }
        }
        return sentryAttributes;
    }
}
