package com.moviesdb;

import javafx.scene.image.Image;

import java.util.Objects;

public class Movie {

    private int movie_ID;
    public String movie_Name;
    public String movie_Genre;
    public String movie_Description;
    public String movie_Duration;
    public String movie_Rating;
    public String movie_Year;
    public String movie_Studio;
    public String movie_Director;

    public String movie_ImageLink;


    //--------Get methods

    public int id(){
        if (movie_ID > 0)
            return movie_ID;
        else
            return -1;
    }

    public String name(){
        return Objects.requireNonNullElse(movie_Name,"Movie_name_undefined");
    }

    public String genre(){
        return Objects.requireNonNullElse(movie_Genre,"Movie_genre_undefined");
    }

    public String description(){
        return Objects.requireNonNullElse(movie_Description,"Movie_description_undefined");
    }

    public String duration(){
        return Objects.requireNonNullElse(movie_Duration,"Movie_duration_undefined");
    }

    public String rating(){
        return Objects.requireNonNullElse(movie_Rating,"Movie_rating_undefined");
    }

    public String year(){
        return Objects.requireNonNullElse(movie_Year,"Movie_year_undefined");
    }

    public String studio(){
        return Objects.requireNonNullElse(movie_Studio,"Movie_studio_undefined");
    }

    public String director(){
        return Objects.requireNonNullElse(movie_Director,"Movie_director_undefined");
    }

    public String getImageLink(){
        return Objects.requireNonNullElse(movie_ImageLink,"Movie_ImageLink_undefined");
    }

    public Image cover(){
        if (movie_ImageLink != null) {
            Image image = new Image(movie_ImageLink);
            return image;
        }
        else {
            Image image = new Image(getClass().getResourceAsStream("media\\coverplaceholder.jpg"));
            return image;
        }
    }


    //--------Set methods

    public int setId(int newID){
        movie_ID = newID;
        return 0;
    }

    public int setName(String newName) {
        movie_Name = newName;
        return 0;
    }

    public int setGenre(String newGenre){
        movie_Genre = newGenre;
        return 0;
    }

    public int setDescription(String newDescription){
        movie_Description = newDescription;
        return 0;
    }

    public int setDuration(String newDuration){
        movie_Duration = newDuration;
        return 0;
    }

    public int setRating(String newRating){
        movie_Rating = newRating;
        return 0;
    }

    public int setYear(String newYear){
        movie_Year = newYear;
        return 0;
    }

    public int setStudio(String newStudio){
        movie_Studio = newStudio;
        return 0;
    }

    public int setDirector(String newDirector){
        movie_Director = newDirector;
        return 0;
    }

    public int setCover(String newImageLink){
        movie_ImageLink = newImageLink;
        return 0;
    }
}
