Package: Presentable
Presentable
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
createPresentationModel() |
|
|
|
|
|
||||||||||||||||||||
createPresentationModel(Object) |
|
|
|
|
|
||||||||||||||||||||
of(Object) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
23: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.role.ui;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Collection;
31: import java.util.Collections;
32: import it.tidalwave.util.Parameters;
33: import it.tidalwave.role.ui.impl.DefaultPresentable;
34: import static it.tidalwave.util.Parameters.r;
35:
36: /***********************************************************************************************************************
37: *
38: * The role of an object that can be presented on a UI, thus is capable of creating a {@link PresentationModel}.
39: *
40: * @stereotype Role
41: *
42: * @author Fabrizio Giudici
43: *
44: **********************************************************************************************************************/
45: @FunctionalInterface
46: public interface Presentable
47: {
48: public static final Class<Presentable> _Presentable_ = Presentable.class;
49:
50: /*******************************************************************************************************************
51: *
52: * Creates a {@link PresentationModel}.
53: *
54: * @return the {@code PresentationModel}
55: * @since 3.2-ALPHA-3 (refactored)
56: *
57: ******************************************************************************************************************/
58: public default PresentationModel createPresentationModel()
59: {
60: return createPresentationModel(Collections.emptyList());
61: }
62:
63: /*******************************************************************************************************************
64: *
65: * Creates a {@link PresentationModel} with some roles.
66: *
67: * @param instanceRoles the roles
68: * @return the {@code PresentationModel}
69: * @since 3.2-ALPHA-3 (refactored)
70: *
71: ******************************************************************************************************************/
72: @Nonnull
73: public PresentationModel createPresentationModel (@Nonnull Collection<Object> instanceRoles);
74:
75: /*******************************************************************************************************************
76: *
77: * Creates a {@link PresentationModel} with a single role.
78: *
79: * @param instanceRole the role
80: * @return the {@code PresentationModel}
81: * @since 3.2-ALPHA-3
82: *
83: ******************************************************************************************************************/
84: @Nonnull
85: public default PresentationModel createPresentationModel (@Nonnull final Object instanceRole)
86: {
87: Parameters.mustNotBeArrayOrCollection(instanceRole, "instanceRole");
88: return createPresentationModel(r(instanceRole));
89: }
90:
91: /*******************************************************************************************************************
92: *
93: * Creates a default {@link Presentable} for the given object.
94: *
95: * @param owner the object
96: * @return the new instance
97: * @since 3.2-ALPHA-2
98: *
99: ******************************************************************************************************************/
100: @Nonnull
101: public static Presentable of (@Nonnull final Object owner)
102: {
103: return new DefaultPresentable(owner);
104: }
105: }