Changeset 7a0bf79 in Git for src/main/java/com/wediscussmovies/project/model/Movie.java
- Timestamp:
- 01/16/22 03:40:31 (3 years ago)
- Branches:
- main
- Children:
- 2a5d6a3
- Parents:
- 839f96a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/model/Movie.java
r839f96a r7a0bf79 1 1 package com.wediscussmovies.project.model; 2 3 import lombok.Data; 2 4 3 5 import javax.persistence.*; 4 6 import java.sql.Date; 7 import java.util.Comparator; 5 8 import java.util.List; 6 9 @Data 7 10 @Entity(name="movies") 8 11 public class Movie { … … 36 39 @ManyToMany(mappedBy = "movie_genres") 37 40 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 } 38 73 } 39 74
Note:
See TracChangeset
for help on using the changeset viewer.