Resolves checkstyle errors for remaining p (#1091)
* Reduces checkstyle errors in page-object * Reduces checkstyle errors in partial-response * Reduces checkstyle errors in pipeline * Reduces checkstyle errors in poison-pill * Reduces checkstyle errors in priority-queue * Reduces checkstyle errors in private-class-data * Reduces checkstyle errors in property * Reduces checkstyle errors in prototype * Reduces checkstyle errors in proxy
This commit is contained in:
committed by
Ilkka Seppälä
parent
1fdc650545
commit
271d7ae9bd
@ -23,18 +23,16 @@
|
||||
|
||||
package com.iluwatar.partialresponse;
|
||||
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Partial response pattern is a design pattern in which client specifies fields to fetch to serve.
|
||||
* Here {@link App} is playing as client for {@link VideoResource} server.
|
||||
* Client ask for specific fields information in video to server.
|
||||
* <p>
|
||||
* <p>
|
||||
* {@link VideoResource} act as server to serve video information.
|
||||
* The Partial response pattern is a design pattern in which client specifies fields to fetch to
|
||||
* serve. Here {@link App} is playing as client for {@link VideoResource} server. Client ask for
|
||||
* specific fields information in video to server.
|
||||
*
|
||||
* <p>{@link VideoResource} act as server to serve video information.
|
||||
*/
|
||||
|
||||
public class App {
|
||||
@ -47,12 +45,12 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map<Integer, Video> videos = Map.of(
|
||||
1, new Video(1, "Avatar", 178, "epic science fiction film",
|
||||
"James Cameron", "English"),
|
||||
2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|",
|
||||
"Hideaki Anno", "Japanese"),
|
||||
3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi",
|
||||
"Christopher Nolan", "English"));
|
||||
1, new Video(1, "Avatar", 178, "epic science fiction film",
|
||||
"James Cameron", "English"),
|
||||
2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|",
|
||||
"Hideaki Anno", "Japanese"),
|
||||
3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi",
|
||||
"Christopher Nolan", "English"));
|
||||
VideoResource videoResource = new VideoResource(new FieldJsonMapper(), videos);
|
||||
|
||||
|
||||
|
@ -26,11 +26,13 @@ package com.iluwatar.partialresponse;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Map a video to json
|
||||
* Map a video to json.
|
||||
*/
|
||||
public class FieldJsonMapper {
|
||||
|
||||
/**
|
||||
* Gets json of required fields from video.
|
||||
*
|
||||
* @param video object containing video information
|
||||
* @param fields fields information to get
|
||||
* @return json of required fields from video
|
||||
|
@ -24,8 +24,7 @@
|
||||
package com.iluwatar.partialresponse;
|
||||
|
||||
/**
|
||||
* {@link Video} is a entity to serve from server.It contains all video related information..
|
||||
* <p>
|
||||
* {@link Video} is a entity to serve from server.It contains all video related information.
|
||||
*/
|
||||
public class Video {
|
||||
private final Integer id;
|
||||
@ -36,23 +35,27 @@ public class Video {
|
||||
private final String language;
|
||||
|
||||
/**
|
||||
* @param id video unique id
|
||||
* @param title video title
|
||||
* @param length video length in minutes
|
||||
* @param description video description by publisher
|
||||
* @param director video director name
|
||||
* @param language video language {private, public}
|
||||
* 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 length, String description, String director, String language) {
|
||||
public Video(Integer id, String title, Integer len, String desc, String director, String lang) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.length = length;
|
||||
this.description = description;
|
||||
this.length = len;
|
||||
this.description = desc;
|
||||
this.director = director;
|
||||
this.language = language;
|
||||
this.language = lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* ToString.
|
||||
*
|
||||
* @return json representaion of video
|
||||
*/
|
||||
@Override
|
||||
|
@ -26,14 +26,16 @@ package com.iluwatar.partialresponse;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The resource class which serves video information.
|
||||
* This class act as server in the demo. Which has all video details.
|
||||
* The resource class which serves video information. This class act as server in the demo. Which
|
||||
* has all video details.
|
||||
*/
|
||||
public class VideoResource {
|
||||
private FieldJsonMapper fieldJsonMapper;
|
||||
private Map<Integer, Video> videos;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param fieldJsonMapper map object to json.
|
||||
* @param videos initialize resource with existing videos. Act as database.
|
||||
*/
|
||||
@ -43,6 +45,8 @@ public class VideoResource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Details.
|
||||
*
|
||||
* @param id video id
|
||||
* @param fields fields to get information about
|
||||
* @return full response if no fields specified else partial response for given field.
|
||||
|
Reference in New Issue
Block a user