Package: ViewFactory$ViewAndController
ViewFactory$ViewAndController
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ViewFactory.ViewAndController(Object, ViewController) |
|
|
|
|
|
||||||||||||||||||||
getController() |
|
|
|
|
|
||||||||||||||||||||
getView() |
|
|
|
|
|
||||||||||||||||||||
renderView(RenderContext) |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.ui;
28:
29: import javax.annotation.Nonnull;
30: import it.tidalwave.util.Id;
31: import it.tidalwave.util.NotFoundException;
32: import it.tidalwave.northernwind.core.model.HttpStatusException;
33: import it.tidalwave.northernwind.core.model.SiteNode;
34: import lombok.Getter;
35: import lombok.RequiredArgsConstructor;
36: import lombok.ToString;
37:
38: /***********************************************************************************************************************
39: *
40: * A factory for Views.
41: *
42: * @stereotype Factory
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @FunctionalInterface
48: public interface ViewFactory
49: {
50: @RequiredArgsConstructor @Getter @ToString
51: public static class ViewAndController
52: {
53: @Nonnull
54: private final Object view;
55:
56: @Nonnull
57: private final ViewController controller;
58:
59: /***************************************************************************************************************
60: *
61: * Call the controller to have the view rendered, and return it.
62: *
63: * @param context the render context
64: * @return the rendered view
65: * @exception Exception if something failed
66: *
67: **************************************************************************************************************/
68: @Nonnull
69: public Object renderView (@Nonnull final RenderContext context)
70: throws Exception
71: {
72: controller.renderView(context);
73: return view;
74: }
75: }
76:
77: /*******************************************************************************************************************
78: *
79: * Creates a new pair of View and Controller.
80: *
81: * @param viewTypeUri the view type URI
82: * @param viewId the view id
83: * @param siteNode the node this view is created for
84: * @return the new pair
85: * @throws NotFoundException if no view component is found
86: * @throws HttpStatusException if a component asked to return a specific HTTP status
87: *
88: ******************************************************************************************************************/
89: @Nonnull
90: public ViewAndController createViewAndController (@Nonnull String viewTypeUri,
91: @Nonnull Id viewId,
92: @Nonnull SiteNode siteNode)
93: throws NotFoundException, HttpStatusException;
94: }