/**
 * Copyright © CENRA (2016)
 *
 * remi.clement@espaces-naturels.fr
 *
 * This software is a multi-platform and portable application based on
 * the scientifical toolbox to monitor wetlands. With this toolbox it’s
 * possible to calculate indicators «RhoMéO» to monitor quality,
 * fonctionalities and urban and agricultural pressures of wetlands.
 * Indicators are calculated using naturalist data entered and/or imported,
 * and geographic data downloaded from a geographic server.
 *
 * This software is governed by the CeCILL license under French law and
 * abiding by the rules of distribution of free software.  You can  use,
 * modify and/ or redistribute the software under the terms of the CeCILL
 * license as circulated by CEA, CNRS and INRIA at the following URL
 * "http://www.cecill.info".
 *
 * As a counterpart to the access to the source code and  rights to copy,
 * modify and redistribute granted by the license, users are provided only
 * with a limited warranty  and the software's author,  the holder of the
 * economic rights,  and the successive licensors  have only  limited
 * liability.
 *
 * In this respect, the user's attention is drawn to the risks associated
 * with loading,  using,  modifying and/or developing or reproducing the
 * software by the user in light of its specific status of free software,
 * that may mean  that it is complicated to manipulate,  and  that  also
 * therefore means  that it is reserved for developers  and  experienced
 * professionals having in-depth computer knowledge. Users are therefore
 * encouraged to load and test the software's suitability as regards their
 * requirements in conditions enabling the security of their systems and/or
 * data to be ensured and,  more generally, to use and operate it in the
 * same conditions as regards security.
 *
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.core.data.reference;

import fr.cenra.rhomeo.api.data.Reference;
import java.util.Objects;

/**
 * Taxref taxonomic referential representation.
 *
 *
 *    Colonne    |         Type         | Modificateurs
 * --------------+----------------------+---------------
 *  regne        | text                 |
 *  phylum       | text                 |
 *  classe       | text                 |
 *  ordre        | text                 |
 *  famille      | text                 |
 *  cd_nom       | character varying(6) | non NULL
 *  cd_taxsup    | character varying(6) |
 *  cd_ref       | character varying(6) |
 *  rang         | text                 |
 *  lb_nom       | text                 |
 *  lb_auteur    | text                 |
 *  nom_complet  | text                 |
 *  nom_valide   | text                 |
 *  nom_vern     | text                 |
 *  nom_vern_eng | text                 |
 *  habitat      | text                 |
 *  fr           | text                 |
 *  gf           | text                 |
 *  mar          | text                 |
 *  gua          | text                 |
 *  sm           | text                 |
 *  sb           | text                 |
 *  spm          | text                 |
 *  may          | text                 |
 *  epa          | text                 |
 *  reu          | text                 |
 *  taaf         | text                 |
 *  pf           | text                 |
 *  nc           | text                 |
 *  wf           | text                 |
 *  cli          | text                 |
 *  aphia_id     | text                 |
 *
 * (Source : base issue du script RhoMéO_Geomatys.backup)
 *
 * @author Samuel Andrés
 *
 * @see TaxrefDescription
 */
public class Taxref implements Reference {

    // META-INFORMATION : ATTRIBUTE NAMES
    // MUST BE CONSISTENT WITH CLASS ATTRIBUTES
    public static final String ATT_CD_NOM = "cd_nom";
    public static final String ATT_CD_TAXSUP = "cd_taxsup";
    public static final String ATT_CD_REF = "cd_ref";
    public static final String ATT_RANG = "rang";
    public static final String ATT_NOM_COMPLET = "nomComplet";

    // Other constants
    public static final String RANG_SSES = "SSES";

    /**
     * Primary key.
     */
    private int cd_nom;

    private int cd_taxsup;

    private int cd_ref;

    private String rang;

    private String lb_nom;

    private String ordre;

    private String classe;

    public int getCd_nom() {
        return cd_nom;
    }

    public void setCd_nom(int cd_nom) {
        this.cd_nom = cd_nom;
    }

    public int getCd_taxsup() {
        return cd_taxsup;
    }

    public void setCd_taxsup(int cd_taxsup) {
        this.cd_taxsup = cd_taxsup;
    }

    public int getCd_ref() {
        return cd_ref;
    }

    public void setCd_ref(int cd_ref) {
        this.cd_ref = cd_ref;
    }

    public String getRang() {
        return rang;
    }

    public void setRang(String rang) {
        this.rang = rang;
    }

    public String getLb_nom() {
        return lb_nom;
    }

    public void setLb_nom(String nomComplet) {
        this.lb_nom = nomComplet;
    }

    public String getOrdre() {
        return ordre;
    }

    public void setOrdre(String ordre) {
        this.ordre = ordre;
    }

    public String getClasse() {
        return classe;
    }

    public void setClasse(String classe) {
        this.classe = classe;
    }

    @Override
    public int hashCode() {
        return cd_nom;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Taxref other = (Taxref) obj;
        if (!Objects.equals(this.cd_nom, other.cd_nom)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return lb_nom;
    }
}
