Skip to content

Commit bf56994

Browse files
committed
iluwatar#1263 - creating ProductController
1 parent 442e1f8 commit bf56994

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.iluwatar.viewhelper;
2+
3+
/**
4+
* Controller delegates a {@link Product} to {@link ProductViewHelper} and then to {@link ConsoleProductView}.
5+
*/
6+
public class ProductController {
7+
8+
private final ViewHelper<Product, ProductViewModel> viewHelper;
9+
private final View<ProductViewModel> view;
10+
11+
public ProductController(ViewHelper<Product, ProductViewModel> viewHelper,
12+
View<ProductViewModel> view) {
13+
this.viewHelper = viewHelper;
14+
this.view = view;
15+
}
16+
17+
/** Passes the product to the helper for formatting and then forwards formatted product to the view. */
18+
public void handle(Product product) {
19+
view.render(viewHelper.prepare(product));
20+
}
21+
}

0 commit comments

Comments
 (0)