]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api.cms/src/org/argeo/api/cms/MvcProvider.java
c1aa6006c793f2ad024481142f0332c5334524f2
1 package org
.argeo
.api
.cms
;
3 import java
.util
.function
.BiFunction
;
6 * Stateless UI part creator. Takes a parent view (V) and a model context (M) in
7 * order to create a view part (W) which can then be further configured. Such
8 * object can be used as services and reference other part of the model which
9 * are relevant for all created UI part.
12 public interface MvcProvider
<V
, M
, W
> extends BiFunction
<V
, M
, W
> {
13 W
createUiPart(V parent
, M context
);
16 * Whether this parent view is supported.
18 * @return true by default.
20 default boolean isViewSupported(V parent
) {
25 * Whether this context is supported.
27 * @return true by default.
29 default boolean isModelSupported(M context
) {
33 default W
apply(V parent
, M context
) {
34 if (!isViewSupported(parent
))
35 throw new IllegalArgumentException("Parent view " + parent
+ "is not supported.");
36 if (!isModelSupported(context
))
37 throw new IllegalArgumentException("Model context " + context
+ "is not supported.");
38 return createUiPart(parent
, context
);
41 default W
createUiPart(V parent
) {
42 return createUiPart(parent
, null);