So, I know that this is possible with the help of a superclass, however this greatly limits flexibility. So now my question is, can I use the interface? Something ala.
interface Taggable {
List<String> addTags(String ... tag)
List<String> removeTags(String ... tag)
}
class User implements Taggable {
String username
static hasMany = [tags:Tag]
}
class Tag {
String name
static hasMany = [references:Taggable]
static belongsTo = Taggable
static constraints = {
name(nullable: false, blank: false, unique: true)
}
}
I'm interested in a link to an object that has the following tag. However, this object cannot propagate a particular class. That's why they are wondering if this can be done using the interface.
So can this be done?
source
share