package io.quarkiverse.operatorsdk.samples.mysqlschema.schema;

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

import io.javaoperatorsdk.operator.processing.ResourceIDProvider;

public class Schema implements Serializable, ResourceIDProvider<String> {

    private final String name;
    private final String characterSet;

    public Schema(String name, String characterSet) {
        this.name = name;
        this.characterSet = characterSet;
    }

    public String getName() {
        return name;
    }

    public String getCharacterSet() {
        return characterSet;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        Schema schema = (Schema) o;
        return Objects.equals(name, schema.name) && Objects.equals(characterSet, schema.characterSet);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, characterSet);
    }

    @Override
    public String toString() {
        return "Schema{" + "name='" + name + '\'' + ", characterSet='" + characterSet + "'}";
    }

    @Override
    public String resourceId() {
        // in this case, we use the naming mechanism as the resource identifying mechanism for ResourceIDProvider
        // so we use the implementation provided by getName
        return getName();
    }
}
