Skip to content

Commit 8fe2ea9

Browse files
Improved some checkstyle changes.
1 parent 17b8999 commit 8fe2ea9

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition/ApiGateway.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
import java.util.Map;
55

66
/**
7-
* ApiGateway class acts as a dynamic routing mechanism that forwards client requests
8-
* to the appropriate frontend components based on dynamically registered routes.
7+
* ApiGateway class acts as a dynamic routing mechanism that forwards client
8+
* requests to the appropriate frontend components based on dynamically
9+
* registered routes.
910
*
10-
* This allows for flexible, runtime-defined routing without hardcoding specific paths.
11+
* <p>This allows for flexible, runtime-defined routing without hardcoding specific paths.
1112
*/
1213
public class ApiGateway {
1314

14-
// A map to store routes dynamically, where the key is the path and the value is the associated FrontendComponent
15+
// A map to store routes dynamically, where the key is the path and the value
16+
// is the associated FrontendComponent
1517
private final Map<String, FrontendComponent> routes = new HashMap<>();
1618

1719
/**
@@ -27,14 +29,14 @@ public void registerRoute(String path, FrontendComponent component) {
2729
/**
2830
* Handles a client request by routing it to the appropriate frontend component.
2931
*
30-
* This method dynamically handles parameters passed with the request, which
32+
* <p>This method dynamically handles parameters passed with the request, which
3133
* allows the frontend components to respond based on those parameters.
3234
*
3335
* @param path the path for which the request is made (e.g., "/products", "/cart")
3436
* @param params a map of parameters that might influence the data fetching logic
3537
* (e.g., filters, userId, categories, etc.)
36-
* @return the data fetched from the appropriate component or "404 Not Found"
37-
* if the path is not registered
38+
* @return the data fetched from the appropriate component or "404 Not Found"
39+
* if the path is not registered
3840
*/
3941
public String handleRequest(String path, Map<String, String> params) {
4042
if (routes.containsKey(path)) {

microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition/CartFrontend.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
public class CartFrontend extends FrontendComponent {
1010

1111
/**
12-
* Fetches the current state of the shopping cart based on dynamic parameters like user ID.
12+
* Fetches the current state of the shopping cart based on dynamic parameters
13+
* like user ID.
1314
*
1415
* @param params parameters that influence the cart data, e.g., "userId"
15-
* @return a string representing the items in the shopping cart for a given user
16+
* @return a string representing the items in the shopping cart for a given
17+
* user
1618
*/
1719
@Override
1820
protected String getData(Map<String, String> params) {
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
package com.iluwatar.clientsideuicomposition;
22

3-
import lombok.extern.slf4j.Slf4j;
43
import java.util.Map;
4+
import lombok.extern.slf4j.Slf4j;
55

66
/**
77
* ClientSideIntegrator class simulates the client-side integration layer that
8-
* dynamically assembles various frontend components into a cohesive user interface.
8+
* dynamically assembles various frontend components into a cohesive user
9+
* interface.
910
*/
1011
@Slf4j
1112
public class ClientSideIntegrator {
1213

1314
private final ApiGateway apiGateway;
1415

1516
/**
16-
* Constructor that accepts an instance of ApiGateway to handle dynamic routing.
17+
* Constructor that accepts an instance of ApiGateway to handle dynamic
18+
* routing.
1719
*
18-
* @param apiGateway the gateway that routes requests to different frontend components
20+
* @param apiGateway the gateway that routes requests to different frontend
21+
* components
1922
*/
2023
public ClientSideIntegrator(ApiGateway apiGateway) {
2124
this.apiGateway = apiGateway;
2225
}
2326

2427
/**
25-
* Composes the user interface dynamically by fetching data from different frontend components
26-
* based on provided parameters.
28+
* Composes the user interface dynamically by fetching data from different
29+
* frontend components based on provided parameters.
2730
*
2831
* @param path the route of the frontend component
2932
* @param params a map of dynamic parameters to influence the data fetching
3033
*/
31-
public void composeUI(String path, Map<String, String> params) {
34+
public void composeUi(String path, Map<String, String> params) {
3235
// Fetch data dynamically based on the route and parameters
3336
String data = apiGateway.handleRequest(path, params);
34-
LOGGER.info("Composed UI Component for path '{}':", path);
37+
LOGGER.info("Composed UI Component for path '" + path + "':");
3538
LOGGER.info(data);
3639
}
3740
}

microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition/FrontendComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public String fetchData(Map<String, String> params) {
2828
}
2929

3030
/**
31-
* Abstract method to be implemented by subclasses to return data based on parameters.
31+
* Abstract method to be implemented by subclasses to return data based on
32+
* parameters.
3233
*
3334
* @param params a map of parameters that may affect the data fetching logic
3435
* @return the data for this specific component

microservices-client-side-ui-composition/src/main/java/com/iluwatar/clientsideuicomposition/ProductFrontend.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class ProductFrontend extends FrontendComponent {
1717
@Override
1818
protected String getData(Map<String, String> params) {
1919
String category = params.getOrDefault("category", "all");
20-
return "Product List for category '" + category + "': [Product 1, Product 2, Product 3]";
20+
return "Product List for category '"
21+
+ category
22+
+ "': [Product 1, Product 2, Product 3]";
2123
}
2224
}

microservices-client-side-ui-composition/src/test/java/com/iluwatar/clientsideuicomposition/ClientSideCompositionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ void testClientSideUIComposition() {
3030
productParams.put("category", "electronics");
3131

3232
// Compose UI for products and cart with dynamic params
33-
integrator.composeUI("/products", productParams);
33+
integrator.composeUi("/products", productParams);
3434

3535
Map<String, String> cartParams = new HashMap<>();
3636
cartParams.put("userId", "user123");
37-
integrator.composeUI("/cart", cartParams);
37+
integrator.composeUi("/cart", cartParams);
3838

3939
// Validate the dynamically fetched data
4040
String productData = apiGateway.handleRequest("/products", productParams);

0 commit comments

Comments
 (0)