🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators Not
This page was created by Lars.olofsson on 2021-05-11. Last edited by Wikiadmin on 2026-07-29.

You use not in OCL expressions to invert a Boolean condition, especially when a nullable Boolean attribute controls a condition such as editing.

Use not to invert a condition

The not operator returns the opposite of a Boolean condition:

Expression Result
not true false
not false true

For a Boolean attribute, write the attribute itself when you mean that it is enabled or set, and prefix it with not when you mean that it is not set.

self.Agreement.Facilitator.DisableEditing
not self.Agreement.Facilitator.DisableEditing

In this example, the first expression tests whether editing is disabled. The second expression tests whether editing is not disabled.

Avoid equality comparisons with nullable Booleans

A nullable Boolean has three possible states: true, false, and null (no value assigned). Do not routinely use = true or = false to test such an attribute.

In particular, do not use the following expression when the intent is to allow editing:

self.Agreement.Facilitator.DisableEditing = false

When DisableEditing is null, this comparison is true. That makes a missing value behave as though the attribute were explicitly false.

Use the direct Boolean form instead:

Intent Preferred expression
Continue only when editing is disabled self.Agreement.Facilitator.DisableEditing
Continue only when editing is not disabled not self.Agreement.Facilitator.DisableEditing

For example, this condition requires a valid-to date, requires that the item has not been added to the journal search, and requires that editing is not disabled:

self.ValidTo.notNull and
self.AddedToJournalSearch.isNull and
not self.Agreement.Facilitator.DisableEditing

Test for a missing value explicitly

Use isNull when your rule specifically needs to know that a value is not assigned. Use notNull when it specifically requires a value.

For example:

self.ValidTo.notNull and
self.AddedToJournalSearch.isNull

These null tests express a different intent from negating a Boolean condition. Use them for absence or presence checks; use not to invert a Boolean condition.

See also