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

import java.io.Serializable;

public final class Track implements Serializable {
    private static final long serialVersionUID = -3488230044171770361L;
    private String duration;
    private String position;
    private String title;
    private String type_;
    private Artist[] artists;
    private Track[] sub_tracks;

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getTitle() {
        return title;
    }

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

    public String getType_() {
        return type_;
    }

    public void setType_(String type_) {
        this.type_ = type_;
    }

    public Artist[] getArtists() {
        return artists;
    }

    public void setArtists(Artist[] artists) {
        this.artists = artists;
    }

    public Track[] getSub_tracks() {
        return sub_tracks;
    }

    public void setSub_tracks(Track[] sub_tracks) {
        this.sub_tracks = sub_tracks;
    }
    
    
    
    /** Helpers **/
    public String getArtistsString() {
        if (artists == null || artists.length == 0) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < artists.length; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(artists[i].getName().replaceAll("\\([0-9]*\\)$", ""));
        }
        return sb.toString();
    }

    @Override
    public String toString() {
        return "Track{" + "duration=" + duration + ", position=" + position + ", title=" + title + ", type_=" + type_ + '}';
    }
    
    
}
