#!/usr/bin/env python
import coral ; metamodel=coral.lang.UML14      # import UML 1.4 metamodel
myModel=metamodel.Model()                 # create a Model
customer=metamodel.Class(name='Customer') # create a class
myModel.ownedElement.insert(customer) # when we add class to the model
assert(customer.namespace==myModel)   # the other association end
                                      # is updated automatically

for expr in [
    'myModel.ownedElement.forAll(lambda c: c.name=="Customer")',
    'myModel.ownedElement.forAll(lambda c1,c2: c1.name!=c2.name or c1==c2)']:
    print expr
    if eval(expr):
        print " is true"
    else:
        print " is false"

print "Model elements:"
for c in myModel.ownedElement:
    print c.name

