package be.msyben.vinylManager.entities;

import java.io.Serializable;

/**
 * Cette classe représente un titre
 * @author Mathieu Syben
 * 
 */
public class Titre implements Serializable, Cloneable {

    /**
     * uid
     */
    private static final long serialVersionUID = -8325896158166055045l;
    
    private String nom;
    private String lyrics;
    private String annee;
    private String artiste = null;
    private int num;
    private int duree;
    private String linkedFilePath;
    

    
    

    /** Creates a new instance of Titre */
    public Titre() {
    }

    /**
     * Getter for property nom.
     *
     * @return Value of property nom.
     */
    public String getNom() {
        return this.nom;
    }

    /**
     * Setter for property nom.
     *
     * @param nom New value of property nom.
     */
    public void setNom(String nom) {
        this.nom = nom;
    }
    /**
     * Getter for property duree.
     *
     * @return Value of property duree.
     */
    public int getDuree() {
        return this.duree;
    }

    /**
     * Setter for property duree.
     *
     * @param duree New value of property duree.
     */
    public void setDuree(int duree) {
        this.duree = duree;
    }

    /**
     * Getter for property num.
     *
     * @return Value of property num.
     */
    public int getNum() {
        return this.num;
    }

    /**
     * Setter for property num.
     *
     * @param num New value of property num.
     */
    public void setNum(int num) {
        this.num = num;
    }

    /**
     * Getter for property artiste.
     *
     * @return Value of property artiste.
     */
    public String getArtiste() {
        return this.artiste;
    }

    /**
     * Setter for property artiste.
     *
     * @param artiste New value of property artiste.
     */
    public void setArtiste(String artiste) {
        this.artiste = artiste;
    }

    /**
     * Get the value of annee
     *
     * @return the value of annee
     */
    public String getAnnee() {
        return annee;
    }

    /**
     * Set the value of annee
     *
     * @param annee new value of annee
     */
    public void setAnnee(String annee) {
        this.annee = annee;
    }

    /**
     * Getter pour lyrics.
     * @return lyrics.
     */
    public String getLyrics() {
        return lyrics;
    }

    /**
     * Setter pour lyrics.
     * @param lyrics lyrics.
     */
    public void setLyrics(String lyrics) {
        this.lyrics = lyrics;
    }

    /**
     * Getter pour linkedFilePath.
     * @return linkedFilePath.
     */
    public String getLinkedFilePath() {
        return linkedFilePath;
    }

    /**
     * Setter pour linkedFilePath.
     * @param linkedFilePath linkedFilePath.
     */
    public void setLinkedFilePath(String linkedFilePath) {
        this.linkedFilePath = linkedFilePath;
    }
    
    
    
    
    @Override
    public String toString() {
        if (artiste == null || artiste.equals("")) {
            if (this.getDuree() != 0) {
                int min = this.getDuree() / 60;
                int sec = this.getDuree() % 60;
                String secS = sec < 10 ? "0" + sec : "" + sec;
                if (this.getAnnee() == null || this.getAnnee().equals("")) {
                    return this.getNum() + " - " + this.getNom() + " (" + min + ":" + secS + ")";
                } else {
                    return this.getNum() + " - " + this.getNom() + " [" + this.getAnnee() + "] (" + min + ":" + secS + ")";
                }
            } else {
                if (this.getAnnee() == null || this.getAnnee().equals("")) {
                    return this.getNum() + " - " + this.getNom();
                } else {
                    return this.getNum() + " - " + this.getNom() + " [" + this.getAnnee() + "]";
                }
            }
        } else {
            if (this.getDuree() != 0) {
                int min = this.getDuree() / 60;
                int sec = this.getDuree() % 60;
                String secS = sec < 10 ? "0" + sec : "" + sec;
                if (this.getAnnee() == null || this.getAnnee().equals("")) {
                    return this.getNum() + " - " + this.getArtiste() + " - " + this.getNom() + " (" + min + ":" + secS + ")";
                } else {
                    return this.getNum() + " - " + this.getArtiste() + " - " + this.getNom() + " [" + this.getAnnee() + "] (" + min + ":" + secS + ")";
                }
            } else {
                if (this.getAnnee() == null || this.getAnnee().equals("")) {
                    return this.getNum() + " - " + this.getArtiste() + " - " + this.getNom();
                } else {
                    return this.getNum() + " - " + this.getArtiste() + " - " + this.getNom() + " [" + this.getAnnee() + "]";
                }
            }
        }
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.nom != null ? this.nom.hashCode() : 0);
        hash = 37 * hash + this.duree;
        hash = 37 * hash + this.num;
        return hash;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Titre)) {
            return false;
        }
        Titre t = (Titre) o;
        if (t.getDuree() == this.getDuree() && t.getNom().equals(this.getNom()) && t.getNum() == this.getNum()) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Titre clone() throws CloneNotSupportedException {
        Titre clone = (Titre) super.clone();
        return clone;
    }
}
