klum-dsl / klum-ast

Turn your models into super models
https://github.com/klum-dsl/klum-ast/wiki
MIT License
3 stars 0 forks source link

Fixed key fields #186

Closed pauxus closed 5 years ago

pauxus commented 5 years ago

For the situation:

@DSL class Server {
  @Key name
}

@DSL class Cluster {

  @Field(fixedKey = "main")
  Server main
  Map<String, Server> servers
}

should create the main methods as for a non keyed Object:

Server main(Closure body) // instead of Server main(String key, Closure body)

an alternative might even be @Field(keyFromField = true)

pauxus commented 5 years ago

or

@Field(key = { value })

In that case, keyFromField could be implemented as empty interface.