package leigh.elements;

import leigh.elements.sdk.ElementsColumnConfig;

import java.util.Objects;

public class ElementsColumnConfigBase implements ElementsColumnConfig {
    private final String name;
    private final String label;
    private final int index;
    private final int width;
    private final String alignment;
    private final boolean isReadOnly;

    public ElementsColumnConfigBase(String name, String label, int index, int width, String alignment, boolean isReadOnly) {
        this.name = name;
        this.label = label;
        this.index = index;
        this.width = width;
        this.alignment = alignment;
        this.isReadOnly = isReadOnly;
    }

    public String getAlignment() {
        return alignment;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public int getColIndex() {
        return index;
    }

    @Override
    public String toString() {
        return "ElementsColumnConfigBase{" +
                "name='" + name + '\'' +
                ", label='" + label + '\'' +
                ", index=" + index +
                ", width=" + width +
                ", alignment='" + alignment + '\'' +
                ", isReadOnly=" + isReadOnly +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ElementsColumnConfigBase that = (ElementsColumnConfigBase) o;
        return index == that.index && width == that.width && isReadOnly == that.isReadOnly && Objects.equals(name, that.name) && Objects.equals(label, that.label) && Objects.equals(alignment, that.alignment);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, label, index, width, alignment, isReadOnly);
    }

    public boolean isReadOnly() {
        return isReadOnly;
    }

    public int getIndex() {
        return index;
    }

    public int getWidth() {
        return width;
    }

    @Override
    public String getLabel() {
        return label;
    }

}
