]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api.cms/src/org/argeo/api/cms/MvcProvider.java
92864ea5c307195f41491ab5b12eb4ca4f5f0a47
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.
13 public interface MvcProvider
<V
, M
, W
> extends BiFunction
<V
, M
, W
> {
14 W
createUiPart(V parent
, M context
);
17 * Whether this parent view is supported.
19 * @return true by default.
21 default boolean isViewSupported(V parent
) {
26 * Whether this context is supported.
28 * @return true by default.
30 default boolean isModelSupported(M context
) {
34 default W
apply(V parent
, M context
) {
35 if (!isViewSupported(parent
))
36 throw new IllegalArgumentException("Parent view " + parent
+ "is not supported.");
37 if (!isModelSupported(context
))
38 throw new IllegalArgumentException("Model context " + context
+ "is not supported.");
39 return createUiPart(parent
, context
);
42 default W
createUiPart(V parent
) {
43 return createUiPart(parent
, null);