mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 04:59:24 +00:00
* Issue #2377: The repository code has been refactored to use the record class * Issue #2377: Refactored according to the rules defined for the repo code * Issue #2377: Refactored according to the rules defined for the repo code * Issue #2377: Refactored according to the rules defined for the repo code
This commit is contained in:
@@ -26,34 +26,10 @@ package com.iluwatar.partialresponse;
|
||||
|
||||
/**
|
||||
* {@link Video} is a entity to serve from server.It contains all video related information.
|
||||
* Video is a record class.
|
||||
*/
|
||||
public class Video {
|
||||
private final Integer id;
|
||||
private final String title;
|
||||
private final Integer length;
|
||||
private final String description;
|
||||
private final String director;
|
||||
private final String language;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id video unique id
|
||||
* @param title video title
|
||||
* @param len video length in minutes
|
||||
* @param desc video description by publisher
|
||||
* @param director video director name
|
||||
* @param lang video language {private, public}
|
||||
*/
|
||||
public Video(Integer id, String title, Integer len, String desc, String director, String lang) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.length = len;
|
||||
this.description = desc;
|
||||
this.director = director;
|
||||
this.language = lang;
|
||||
}
|
||||
|
||||
public record Video(Integer id, String title, Integer length, String description, String director, String language) {
|
||||
/**
|
||||
* ToString.
|
||||
*
|
||||
@@ -62,12 +38,12 @@ public class Video {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{"
|
||||
+ "\"id\": " + id + ","
|
||||
+ "\"title\": \"" + title + "\","
|
||||
+ "\"length\": " + length + ","
|
||||
+ "\"description\": \"" + description + "\","
|
||||
+ "\"director\": \"" + director + "\","
|
||||
+ "\"language\": \"" + language + "\","
|
||||
+ "}";
|
||||
+ "\"id\": " + id + ","
|
||||
+ "\"title\": \"" + title + "\","
|
||||
+ "\"length\": " + length + ","
|
||||
+ "\"description\": \"" + description + "\","
|
||||
+ "\"director\": \"" + director + "\","
|
||||
+ "\"language\": \"" + language + "\","
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user