🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperatorsNotEmpty
This page was created by Peter on 2019-11-22. Last edited by Wikiadmin on 2026-07-29.

Use notEmpty in an OCL expression when you need to test whether the value represented by self contains one or more elements.

Return value

The operator returns a Boolean value:

Condition Result
self contains at least one element true
self contains no elements false

In this context, self is the value that the OCL expression evaluates. Use the result where a Boolean condition is required.

Example

Suppose self represents a collection of order lines:

  • If the collection contains one or more order lines, notEmpty returns true.
  • If the collection contains no order lines, notEmpty returns false.

For example, you can use this test as a condition that requires an order to have at least one order line before the condition succeeds.

See also