On 5 October 2012 12:13, Minto van der Sluis <mi...@xup.nl> wrote:

>
> Can you give an example of what you think this DSL should look like?
>
>
Off the top of my head, I've just come up with the following....

Comments welcome!


* For entities:*

@... // annotations here
entity Customer {
   ...

  ProductRepository products;
  OrderRepository orders;
}


where:
- the products, orders imply an instance variable and a setter to allow
services to be injected into
- DomainObjectContainer container is provided automatically as a field


For entity properties:

entity Customer {

  @ ... // annotations here
  property String firstName {
    set;
    modify { ... }
    clear { }
    default { ... }
    choices { ... }
    hide { ... }
    disable { ... }
    validate { ... }
  }
}


where
- property is a keyword
- String firstName
  - implies the instance variable and the getter
  - annotations can be specified, apply to the getter
- set;
  - is optional,
  - if present implies the setter (and so is a non-derived property)
  - syntax borrowed from C#
- modify { ... }
  - is optional
  - if present, implies the modifyXxx(String value) method
  - 'value' would be an implicitly available locally scoped parameter
- clear { ... }
  - is optional
  - if present, implies the void clearXxx() method
- default { ... }
  - is optional
  - if present, implies the String defaultXxx() method
- choices { ... }
  - is optional
  - if present, implies the List<String> choicesXxx() method
- hide { ... }
  - is optional
  - if present, implies the boolean clearXxx() method
- disable { ... }
  - is optional
  - if present, implies the String disableXxx() method
- validate { ... }
  - is optional
  - if present, implies the String validateXxx(String value) method
  - 'value' would be an implicitly available locally scoped parameter


similarly for entity collections:

entity Customer {

  @ ... // annotations here
  collection List<Order> orders {
    addTo { ... }
    removeFrom { }
    hide { ... }
    disable { ... }
    validateAddTo { ... }
    validateRemoveFrom { ... }
  }
}

where
- collection is a keyword
- otherwise similarly as properties


and similarly for entity actions:

entity Customer {

  @... // annotations here
  action Order placeOrder(
      Product product {
        default { }
        choices { }
        validate { }
      },
      int quantity {
        default { }
        choices { }
        validate { }
      }
    ) {
    body { ... }
    hide { ... }
    disable { ... }
    validate { ... }
  }
}


where
- the name of the parameter would imply @Named(...)
- the default, choices, validate for the parameters apply to that parameter
  - imply corresponding defaultNXxx(), choicesNXxx, validateNXxx()
    - where N = parameter number
- body { ... }
  - is the action body, with the parameters defined
- hide, disable
  - similarly
- validate (at action level)
  - corresponds to validateXxx(...)
  - to validate the set of arguments rather than an individual parameter



Any members that do not follow the above rules are just copied over "as-is"
into Java.


~~~~~~~~~~~~
For values:

value FractionalNumber {
  int numerator;
  int denominator;
}


is basically the same as Lombok @Data
requires information in @ValueSemanticsProvider to be specified (somehow,
not sure exactly how)


~~~~~~~~~~~~
For services/repositories:

service ProductRepository {

}

where:
- any services are injected into as for entities
- DomainObjectContainer container is provided for free, again as for
entities
- actions as for entities
- properties and collections are disallowed

Reply via email to