Using Xtend active annotations, the following code is converted automagically into a EMF-based meta-model and API.
This project is currently just a proof-of-concept. It only covers a very small portion of EMF.
@XMFPackage
creates EPackage
+ EFactory
classes@XMF
for classes of the meta model@Contained
for containment relation@Invariant
marks validation methods. XMF will automatically create the Validator class as necessary@DerivedAttribute
for attributes whose value is computed in a methodList<T>
is treated as a attribute/reference of cardinality 0..*
and mapped to EList<T>
EOperations
@XMFPackage("http://some/eNS_URI")
@XMF abstract class NamedEntity {
@ID String name
@Invariant("name must be smaller than 10 characters")
def nameSizeConstraint() {
name.length < 10
}
@Invariant("name cannot be empty")
def nameNotEmpty() {
! name.empty
}
}
@XMF class User extends NamedEntity {
List<String> phones
@OppositeOf("users") Group group
@Contained Account userAccount
def someOperation() {
...
}
private def helperMethod() {
...
}
}
@XMF class Group extends NamedEntity {
@Contained List<User> users
@DerivedAttribute def paidUsers() {
users.filter[salary > 0]
}
}
@XMF class Account {
int salary = 0
}