package io.delphiplatform.api.v3.model.localization;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import io.delphiplatform.api.v3.rdb.entity.CountryLocaleEntity;

@JsonPropertyOrder(alphabetic = true)
public class RegionTranslation {

    @JsonProperty("country_name")
    private String countryName;

    public static RegionTranslation from(CountryLocaleEntity countryLocaleEntity) {
        if (countryLocaleEntity == null) {
            return null;
        }
        return new RegionTranslation()
            .countryName(countryLocaleEntity.getCountryName());
    }

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }

    public RegionTranslation countryName(String countryName) {
        this.countryName = countryName;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        RegionTranslation that = (RegionTranslation) o;
        return Objects.equal(countryName, that.countryName);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(countryName);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
            .add("countryName", countryName)
            .toString();
    }

}
