Skip to main content

Create a Class

Class

To create a class:

  1. Right-click any package on the left side of the panel, or click the + near the name of your project.

  2. Under Class view, you'll see a list of class forms as well as a diagram view of your class. You can add tags, stereotypes, properties, constraints, qualified properties, and super types to your model.

  3. Click the + icon. Make sure the correct package (i.e. demo) is selected.

  4. Click New class.

    Let's create 2 classes. One that is called Person and another one that is called Firm.

    Studio displays a visualization of the class and a tabbed list of the possible model enrichments.

create class

In the basic logical modeling, Account, Product, and Trade are classes.

Property

Class properties define attributes of a business concept. To create a property:

Property - primitive data type

  1. Select the Person and Firm class respectively.

  2. Go to the Properties tab and click the + icon.

  3. Type in the name of your property and specify the data type and cardinality.

    For our Person class, let's create a property called firstName of type String with cardinality of 1. Let's add the property id of type String with the cardinality of 1 in our Firm class.

add property

Property - non-primitive data type

Create a relationship between the Person and Firm classes.

  1. Select the Firm class,
  2. Create property with the following values:
    • Name: employees
    • Type: Person
    • Cardinality: 0..

Add a super type

Derived property

To create a derived property:

  1. Select the Person class.

  2. Go to the Derived properties tab and click the + icon.

  3. Type in the name of your property and specify the data type and cardinality.

  4. Type in the expression.

    Let's add a derived property called firstNameCount using the following expression: $this.firstName->count().

  5. Select a return data type of Integer and cardinality of 1.

  6. Press F9 to compile the expression.

add derived property

Quality control for properties

Type

COMING SOON

Multiplicity

COMING SOON

Enumeration

COMING SOON

Constraint

COMING SOON

Constraint

To add a constraint:

  1. Select the Person class.

  2. Go to the Constraints tab and click the + icon.

  3. Type in a name for the constraint and the expression.

    Let's add a constraint called firstNameNotEmpty using the following expression: $this.firstName->isNotEmpty().

  4. Press F9 to compile the expression.

add constraint

Model constraint feedback

When typing constraints and qualified properties, you will get immediate parsing feedback. You can compile your code by pressing F9.

More