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

package com.google.crypto.tink.internal;

import java.util.Collections;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.HashMap;
import java.util.Map;
import com.google.crypto.tink.annotations.Alpha;
import com.google.errorprone.annotations.Immutable;

@Immutable
@Alpha
public final class MonitoringAnnotations
{
    public static final MonitoringAnnotations EMPTY;
    private final Map<String, String> entries;
    
    private MonitoringAnnotations(final Map<String, String> entries) {
        this.entries = entries;
    }
    
    public static Builder newBuilder() {
        return new Builder();
    }
    
    public Map<String, String> toMap() {
        return this.entries;
    }
    
    public boolean isEmpty() {
        return this.entries.isEmpty();
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (!(obj instanceof MonitoringAnnotations)) {
            return false;
        }
        final MonitoringAnnotations that = (MonitoringAnnotations)obj;
        return this.entries.equals(that.entries);
    }
    
    @Override
    public int hashCode() {
        return this.entries.hashCode();
    }
    
    @Override
    public String toString() {
        return this.entries.toString();
    }
    
    static {
        EMPTY = newBuilder().build();
    }
    
    public static final class Builder
    {
        private HashMap<String, String> builderEntries;
        
        public Builder() {
            this.builderEntries = new HashMap<String, String>();
        }
        
        @CanIgnoreReturnValue
        public Builder addAll(final Map<String, String> newEntries) {
            if (this.builderEntries == null) {
                throw new IllegalStateException("addAll cannot be called after build()");
            }
            this.builderEntries.putAll(newEntries);
            return this;
        }
        
        @CanIgnoreReturnValue
        public Builder add(final String name, final String value) {
            if (this.builderEntries == null) {
                throw new IllegalStateException("add cannot be called after build()");
            }
            this.builderEntries.put(name, value);
            return this;
        }
        
        public MonitoringAnnotations build() {
            if (this.builderEntries == null) {
                throw new IllegalStateException("cannot call build() twice");
            }
            final MonitoringAnnotations output = new MonitoringAnnotations(Collections.unmodifiableMap((Map<?, ?>)this.builderEntries), null);
            this.builderEntries = null;
            return output;
        }
    }
}
