File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
vertigo-datastore/src/main/java/io/vertigo/datastore/impl/entitystore Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 24
24
import io .vertigo .datamodel .data .model .ListVAccessor ;
25
25
import io .vertigo .datastore .entitystore .EntityStoreManager ;
26
26
27
+ /**
28
+ * This class is a way to access a list of foreign entities defined by a relationship.
29
+ * It's a kind of box (aka optional) that offers a small list of methods.
30
+ *
31
+ * @author pchretien, mlaroche, npiedeloup *
32
+ * @param <E> the type of entity
33
+ */
27
34
public class StoreListVAccessor <E extends Entity > extends ListVAccessor <E > {
28
35
29
36
private static final long serialVersionUID = -4840484505809842010L ;
@@ -52,4 +59,26 @@ public final void set(final DtList<E> dtList) {
52
59
throw new VSystemException ("StoreListVAccessor cannot be set, you can only load it" );
53
60
}
54
61
62
+ /**
63
+ * Loads the value if needed.
64
+ */
65
+ public void loadIfAbsent () {
66
+ if (getSourceUID () != null && !isLoaded ()) {
67
+ load ();
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Loads the value if needed.
73
+ * @deprecated This usage is discouraged : prefer explicit loading by using load() then get()
74
+ */
75
+ @ Deprecated
76
+ public DtList <E > lazyGet () {
77
+ if (getSourceUID () == null ) {
78
+ return null ;
79
+ }
80
+ loadIfAbsent ();
81
+ return get ();
82
+ }
83
+
55
84
}
Original file line number Diff line number Diff line change 26
26
* This class is a way to access an entity defined by a relationship.
27
27
* It's a kind of box (aka optional) that offers a small list of methods.
28
28
*
29
- * @author pchretien
29
+ * @author pchretien, mlaroche, npiedeloup
30
30
*
31
31
* @param <E> the type of entity
32
32
*/
@@ -54,4 +54,26 @@ public void load() {
54
54
}
55
55
}
56
56
57
+ /**
58
+ * Loads the value if needed.
59
+ */
60
+ public void loadIfAbsent () {
61
+ if (getUID () != null && !isLoaded ()) {
62
+ load ();
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Loads the value if needed.
68
+ * @deprecated This usage is discouraged : prefer explicit loading by using load() then get()
69
+ */
70
+ @ Deprecated
71
+ public E lazyGet () {
72
+ if (getUID () == null ) {
73
+ return null ;
74
+ }
75
+ loadIfAbsent ();
76
+ return get ();
77
+ }
78
+
57
79
}
You can’t perform that action at this time.
0 commit comments