Constraints are relations among attribute variables or components. They can appear in component and attribute declarations, and can also appear in classes as member declarations themselves. Reconsider our HelloWorld example. We can write the constraint on bt separately from the component declaration as follows:
main class HelloWorld { component Button bt; // component declaration bt.text == "Hello World!"; // constraint }
In general, constraints have the same form as conditional expressions in Java. The DJ compile can distinguish constraints from conditional expressions from the context in which they appear.
A constraint is either a basic one or a composite one. A basic constraint is a domain, an arithmetic, a symbolic, or a call to a user defined constraint. A composite constraint is made up of basic constraints and various connectives.