|
20 | 20 | import java.io.Serializable; |
21 | 21 |
|
22 | 22 | /** |
23 | | - * Interface representing a view with a value and descriptor. |
| 23 | + * Core abstraction for a UI view that holds a typed value and is driven by a {@link ViewDescriptor}. |
24 | 24 | * |
25 | | - * @param <T> the type of value managed by the view |
| 25 | + * <p>A {@code View} is the runtime representation of a UI component built by a {@link ViewRenderer}. |
| 26 | + * It is parameterized by the type {@code T} of the domain object (or value) it displays or edits. |
| 27 | + * The structure and behaviour of the view are defined by its associated {@link ViewDescriptor}.</p> |
| 28 | + * |
| 29 | + * <p>Views can be nested: a view may have a parent view, allowing composite UI hierarchies to be |
| 30 | + * constructed (e.g., a sub-form embedded inside a main form).</p> |
| 31 | + * |
| 32 | + * <p>Typical lifecycle: |
| 33 | + * <ol> |
| 34 | + * <li>A {@link ViewDescriptor} is resolved by {@link ViewDescriptorFactory}.</li> |
| 35 | + * <li>A {@code View} instance is created by {@link ViewFactory} using a {@link ViewRenderer}.</li> |
| 36 | + * <li>A value is set via {@link #setValue(Object)}, causing the view to reflect the domain object.</li> |
| 37 | + * </ol> |
| 38 | + * </p> |
| 39 | + * |
| 40 | + * @param <T> the type of the domain object (value) managed by this view |
| 41 | + * @see ViewDescriptor |
| 42 | + * @see ViewFactory |
| 43 | + * @see ViewRenderer |
26 | 44 | */ |
27 | 45 | public interface View<T> extends Serializable { |
28 | 46 |
|
29 | 47 | /** |
30 | | - * Gets the value of the view. |
| 48 | + * Returns the current value held by this view. |
31 | 49 | * |
32 | | - * @return the value |
| 50 | + * @return the current value, or {@code null} if no value has been set |
33 | 51 | */ |
34 | 52 | T getValue(); |
35 | 53 |
|
36 | 54 | /** |
37 | | - * Sets the value of the view. |
| 55 | + * Sets the value to be displayed or edited by this view. |
| 56 | + * |
| 57 | + * <p>Implementations should update the visual state of the view to reflect the new value.</p> |
38 | 58 | * |
39 | | - * @param value the new value |
| 59 | + * @param value the new value; may be {@code null} |
40 | 60 | */ |
41 | 61 | void setValue(T value); |
42 | 62 |
|
43 | 63 | /** |
44 | | - * Sets the view descriptor. |
| 64 | + * Assigns the {@link ViewDescriptor} that defines the structure and metadata of this view. |
45 | 65 | * |
46 | | - * @param viewDescriptor the new view descriptor |
| 66 | + * <p>This is typically called once during view construction by the {@link ViewFactory}.</p> |
| 67 | + * |
| 68 | + * @param viewDescriptor the descriptor to associate with this view; must not be {@code null} |
47 | 69 | */ |
48 | 70 | void setViewDescriptor(ViewDescriptor viewDescriptor); |
49 | 71 |
|
50 | 72 | /** |
51 | | - * Gets the view descriptor. |
| 73 | + * Returns the {@link ViewDescriptor} that describes the structure and metadata of this view. |
52 | 74 | * |
53 | | - * @return the view descriptor |
| 75 | + * @return the view descriptor; may be {@code null} if not yet initialized |
54 | 76 | */ |
55 | 77 | ViewDescriptor getViewDescriptor(); |
56 | 78 |
|
57 | 79 | /** |
58 | | - * Gets the parent view. |
| 80 | + * Returns the parent view that contains this view, if any. |
| 81 | + * |
| 82 | + * <p>Used to navigate composite view hierarchies.</p> |
59 | 83 | * |
60 | | - * @return the parent view |
| 84 | + * @return the parent {@link View}, or {@code null} if this is a top-level view |
61 | 85 | */ |
62 | 86 | View getParentView(); |
63 | 87 |
|
64 | 88 | /** |
65 | | - * Sets the parent view. |
| 89 | + * Sets the parent view that contains this view. |
66 | 90 | * |
67 | | - * @param view the new parent view |
| 91 | + * @param view the parent {@link View}; may be {@code null} for top-level views |
68 | 92 | */ |
69 | 93 | void setParentView(View view); |
70 | 94 |
|
| 95 | + /** |
| 96 | + * Sets an arbitrary source object associated with this view. |
| 97 | + * |
| 98 | + * <p>The source can represent the originating controller, component, or context object. |
| 99 | + * The default implementation is a no-op; subclasses may override to store the value.</p> |
| 100 | + * |
| 101 | + * @param source the source object; may be {@code null} |
| 102 | + */ |
71 | 103 | default void setSource(Object source) { |
72 | | - |
73 | 104 | } |
74 | 105 |
|
| 106 | + /** |
| 107 | + * Returns the source object previously set via {@link #setSource(Object)}. |
| 108 | + * |
| 109 | + * <p>The default implementation always returns {@code null}; subclasses may override.</p> |
| 110 | + * |
| 111 | + * @return the source object, or {@code null} if not set |
| 112 | + */ |
75 | 113 | default Object getSource() { |
76 | 114 | return null; |
77 | 115 | } |
|
0 commit comments