@@ -3,67 +3,72 @@ package org.grails.datastore.gorm
33/**
44 * API for instance methods defined by a GORM entity
55 *
6+ * To use GORM domain inheritance with Groovy 4, {@link GormEntityApi} should be converted to a `Trait,
7+ *
8+ * https://issues.apache.org/jira/browse/GROOVY-5106
9+ * https://issues.apache.org/jira/browse/GROOVY-11508
10+ *
611 * @author Graeme Rocher
712 * @since 5.0.5
813 *
914 * @param <D> The entity type
1015 */
11- interface GormEntityApi <D> {
16+ trait GormEntityApi<D> {
1217
1318 /**
1419 * Proxy aware instanceOf implementation.
1520 */
16- boolean instanceOf (Class cls )
21+ abstract boolean instanceOf(Class cls)
1722
1823 /**
1924 * Upgrades an existing persistence instance to a write lock
2025 * @return The instance
2126 */
22- D lock ()
27+ abstract D lock()
2328
2429 /**
2530 * Locks the instance for updates for the scope of the passed closure
2631 *
2732 * @param callable The closure
2833 * @return The result of the closure
2934 */
30- def mutex (Closure callable )
35+ abstract def mutex(Closure callable)
3136
3237 /**
3338 * Refreshes the state of the current instance
3439 * @return The instance
3540 */
36- D refresh ()
41+ abstract D refresh()
3742
3843 /**
3944 * Saves an object the datastore
4045 * @return Returns the instance
4146 */
42- D save ()
47+ abstract D save()
4348
4449 /**
4550 * Forces an insert of an object to the datastore
4651 * @return Returns the instance
4752 */
48- D insert ()
53+ abstract D insert()
4954
5055 /**
5156 * Forces an insert of an object to the datastore
5257 * @return Returns the instance
5358 */
54- D insert (Map params )
59+ abstract D insert(Map params)
5560
5661 /**
5762 * Saves an object the datastore
5863 * @return Returns the instance
5964 */
60- D merge ()
65+ abstract D merge()
6166
6267 /**
6368 * Saves an object the datastore
6469 * @return Returns the instance
6570 */
66- D merge (Map params )
71+ abstract D merge(Map params)
6772
6873 /**
6974 * Save method that takes a boolean which indicates whether to perform validation or not
@@ -72,46 +77,46 @@ interface GormEntityApi<D> {
7277 *
7378 * @return The instance or null if validation fails
7479 */
75- D save (boolean validate )
80+ abstract D save(boolean validate)
7681
7782 /**
7883 * Saves an object with the given parameters
7984 * @param instance The instance
8085 * @param params The parameters
8186 * @return The instance
8287 */
83- D save (Map params )
88+ abstract D save(Map params)
8489
8590 /**
8691 * Returns the objects identifier
8792 */
88- Serializable ident ()
93+ abstract Serializable ident()
8994
9095 /**
9196 * Attaches an instance to an existing session. Requries a session-based model
9297 * @return
9398 */
94- D attach ()
99+ abstract D attach()
95100
96101 /**
97102 * No concept of session-based model so defaults to true
98103 */
99- boolean isAttached ()
104+ abstract boolean isAttached()
100105
101106 /**
102107 * Discards any pending changes. Requires a session-based model.
103108 */
104- void discard ()
109+ abstract void discard()
105110
106111 /**
107112 * Deletes an instance from the datastore
108113 */
109- void delete ()
114+ abstract void delete()
110115
111116 /**
112117 * Deletes an instance from the datastore
113118 */
114- void delete (Map params )
119+ abstract void delete(Map params)
115120
116121 /**
117122 * Checks whether a field is dirty
@@ -121,14 +126,14 @@ interface GormEntityApi<D> {
121126 *
122127 * @return true if the field is dirty
123128 */
124- boolean isDirty (String fieldName )
129+ abstract boolean isDirty(String fieldName)
125130
126131 /**
127132 * Checks whether an entity is dirty
128133 *
129134 * @param instance The instance
130135 * @return true if it is dirty
131136 */
132- boolean isDirty ()
137+ abstract boolean isDirty()
133138
134139}
0 commit comments