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

package io.sentry.config;

import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import io.sentry.util.StringUtils;
import io.sentry.util.Objects;
import java.util.Properties;
import org.jetbrains.annotations.NotNull;

abstract class AbstractPropertiesProvider implements PropertiesProvider
{
    @NotNull
    private final String prefix;
    @NotNull
    private final Properties properties;
    
    protected AbstractPropertiesProvider(@NotNull final String prefix, @NotNull final Properties properties) {
        this.prefix = Objects.requireNonNull(prefix, "prefix is required");
        this.properties = Objects.requireNonNull(properties, "properties are required");
    }
    
    protected AbstractPropertiesProvider(@NotNull final Properties properties) {
        this("", properties);
    }
    
    @Nullable
    @Override
    public String getProperty(@NotNull final String property) {
        return StringUtils.removeSurrounding(this.properties.getProperty(this.prefix + property), "\"");
    }
    
    @NotNull
    @Override
    public Map<String, String> getMap(@NotNull final String property) {
        final String prefix = this.prefix + property + ".";
        final Map<String, String> result = new HashMap<String, String>();
        for (final Map.Entry<Object, Object> entry : this.properties.entrySet()) {
            if (entry.getKey() instanceof String && entry.getValue() instanceof String) {
                final String key = entry.getKey();
                if (!key.startsWith(prefix)) {
                    continue;
                }
                final String value = StringUtils.removeSurrounding(entry.getValue(), "\"");
                result.put(key.substring(prefix.length()), value);
            }
        }
        return result;
    }
}
