package com.atlassian.stash.internal.plugin;

import java.io.Serializable;
import java.util.Objects;

/**
 * Cache key for {@link DefaultPluginSettings}
 */
class PluginSettingKey implements Serializable {
    private static final long serialVersionUID = 1L;

    public final String namespace;
    public final String key;

    PluginSettingKey(String namespace, String key) {
        this.namespace = namespace;
        this.key = key;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof PluginSettingKey) {
            PluginSettingKey that = (PluginSettingKey) other;
            return namespace.equals(that.namespace) && key.equals(that.key);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(namespace, key);
    }

    @Override
    public String toString() {
        return namespace + "::" + key;
    }
}
