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

Layer3: AutoLink to value determined by other field #302

Open pauxus opened 1 year ago

pauxus commented 1 year ago
@DSL class House {

  Map<String, Room> rooms

}

@DSL class Room {
  @Key String name
  @Owner House house

  List<String> adjacentRoomNames

  @LinkTo(provider = {house.rooms}, selector = 'adjacentRoomNames')
  List<Room> adjacentRooms

}

House.Create.With {
  room("LivingRoom")  {
    adjacentRoomNames("Kitchen", "DiningRoom")
  }
  room("DiningRoom")
  room("Kitchen")
  room("Bedroom")

}

What about bidrectional links?