property
valuesDeclares an expression
over modeling property
values, which will fail parsing, if it yields false
or nil
.
Referring to the Ring library, which is introduced for the property
example,
library Ring
class Ring
property InnerRadius
type: real
constraint: . > 0
property OuterRadius
type: real
constraint: . > InnerRadius
function Contains
static
parameter x
parameter y
expression: InnerRadius <= l and l <= OuterRadius
where l: sqrt(x*x+y*y)
we may declare a thin ring with a modelconstraint
stating that the ring is no thicker than a tenth of the inner radius:
site ThinRing
references: Ring
Ring ThinRing
abstract # because we set no values for inner and outer radii
modelconstraint:OuterRadius <= InnerRadius * 1.10
ThinRing TenToEleven
InnerRadius: 10
OuterRadius: 11
ThinRing NineToTenIsNotThinEnough
InnerRadius: 9
OuterRadius: 10
Note, that
- to avoid a parsing error,
ThinRing
must be declaredabstract
, because it does not specify values for its radii whose constraint expressions would fail for a non-abstract class, and that- parsing the last sample class,
NineToTenIsNotThinEnough
, will fail.