1
2
3
4
5
6
7
8
9
10
11 @FunctionalInterface
12 public interface MvcProvider<V, M, W> extends BiFunction<V, M, W> {
13 W createUiPart(V parent, M context);
14
15
16
17
18
19
20 default boolean isViewSupported(V parent) {
21 return true;
22 }
23
24
25
26
27
28
29 default boolean isModelSupported(M context) {
30 return true;
31 }
32
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);
39 }
40
41 default W createUiPart(V parent) {
42 return createUiPart(parent, null);
43 }
44 }