Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using modular traits in Groovy 2.3.0-beta-1
trait HasId {
long id
trait HasVersion {
long version
trait Persistent {
boolean save() { println "saving ${this.dump()}" }
trait Entity implements Persistent, HasId, HasVersion {
boolean save() {
class Publication implements Entity {
String title
class Book extends Publication {
String isbn
Entity gina = new Book(id:1, version:1, title:"gina", isbn:"111111")
assert gina.version == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment