Ignore:
Timestamp:
01/16/22 03:40:31 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
2a5d6a3
Parents:
839f96a
Message:

Early implementations, MovieController CRUD implementation included

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r839f96a r7a0bf79  
    11package com.wediscussmovies.project.model;
     2
     3import lombok.Data;
    24
    35import javax.persistence.*;
    46import java.sql.Date;
     7import java.util.Comparator;
    58import java.util.List;
    6 
     9@Data
    710@Entity(name="movies")
    811public class Movie {
     
    3639    @ManyToMany(mappedBy = "movie_genres")
    3740    private List<Genre> genres;
     41
     42    public boolean isFromGenre(Genre genre){
     43        for(Genre g: genres){
     44            if(g.getGenre_id() == genre.getGenre_id())
     45                return true;
     46        }
     47        return false;
     48    }
     49    public boolean hasActor(Person p){
     50        for(Person person: actors){
     51            if(person.getPerson_id() == p.getPerson_id())
     52                return true;
     53        }
     54        return false;
     55    }
     56
     57    public boolean isDirectedBy(Person p){
     58        return director.getPerson_id() == p.getPerson_id();
     59    }
     60
     61    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
     62
     63    public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) {
     64        Title = title;
     65        this.description = description;
     66        this.image_url = image_url;
     67        this.airing_date = airing_date;
     68        this.imdb_rating = imdb_rating;
     69        this.director = director;
     70        this.actors = actors;
     71        this.genres = genres;
     72    }
    3873}
    3974
Note: See TracChangeset for help on using the changeset viewer.