forked from hanghae-skillup/redis_1st
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovieSearchRequest.java
More file actions
34 lines (28 loc) · 912 Bytes
/
MovieSearchRequest.java
File metadata and controls
34 lines (28 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.example.movie.request;
import com.example.movie.dto.GenreDto;
import lombok.Getter;
import static com.example.exception.BusinessError.*;
@Getter
public class MovieSearchRequest {
private String title;
private String genre;
public MovieSearchRequest(String title, String genre) {
this.title = title;
this.genre = genre;
}
private void validate() {
if (this.title != null && this.title.length() > 225) {
throw MOVIE_SEARCH_TITLE_ERROR.exception();
}
if (this.genre != null && !GenreDto.isValidGenre(this.genre)) {
throw MOVIE_SEARCH_GENRE_ERROR.exception();
}
}
public MovieSearchServiceRequest toServiceRequest() {
this.validate();
return MovieSearchServiceRequest.builder()
.title(this.title)
.genre(this.genre)
.build();
}
}