package be.msyben.vinylManager.tools.musicBrainz.entities;

import com.google.gson.annotations.SerializedName;

public final class Release implements Comparable<Release> {
    private String id;
    private Integer score;
    private int count;
    private String title;
    private String status;
    private String packaging;
    @SerializedName("artist-credit") private ArtistCredit[] artistCredit;
    private String date;
    private String country;
    private String barcode;
    private Media[] media;
    @SerializedName("track-count") private int trackCount;
    @SerializedName("label-info") private LabelInfo[] labelInfo;

    private Integer distance;
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getPackaging() {
        return packaging;
    }

    public void setPackaging(String packaging) {
        this.packaging = packaging;
    }

    public ArtistCredit[] getArtistCredit() {
        return artistCredit;
    }

    public void setArtistCredit(ArtistCredit[] artistCredit) {
        this.artistCredit = artistCredit;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public Media[] getMedia() {
        return media;
    }

    public void setMedia(Media[] media) {
        this.media = media;
    }

    public int getTrackCount() {
        return trackCount;
    }

    public void setTrackCount(int trackCount) {
        this.trackCount = trackCount;
    }

    public Integer getDistance() {
        return distance;
    }

    public void setDistance(Integer distance) {
        this.distance = distance;
    }
    
    
    
    

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (artistCredit != null) {
            for (ArtistCredit aa : artistCredit) {
                if (aa.getArtist() != null) {
                    sb.append(aa.getArtist().getName()).append(" ");
                }
            }
        }
        sb.append(" - ").append(title);
        sb.append(" (").append(trackCount).append(" tracks) ");
        if (media != null && media.length > 0 && media[0].getFormat() != null && !media[0].getFormat().isEmpty()) sb.append(" (").append(media[0].getFormat()).append(")");
        if (country != null && !country.isEmpty()) sb.append(" (").append(country).append(")");
        if (date != null && !date.isEmpty()) sb.append(" (").append(date).append(")");
        if (labelInfo != null && labelInfo.length > 0 && labelInfo[0].getCatalogNumber() != null && !labelInfo[0].getCatalogNumber().isEmpty()) sb.append(" (").append(labelInfo[0].getCatalogNumber()).append(")");
        if (score != null) sb.append(" (").append(score).append(")");
        return sb.toString();
    }

    @Override
    public int compareTo(Release o) {
        int comp = this.score.compareTo(o.score);
        if (comp != 0) {
            return comp;
        }
        
        return distance.compareTo(o.distance);
    }
    
    
    
}
