Skip to content

Simple types

A simple type gives a domain value a name without declaring fields. The CMN grammar defines the declaration shape; the selected profile supplies stereotypes, properties, and usually the types from which application-specific types are derived.

1. Declaration syntax

text
[description] [abstract] type [<stereotypes>] Name
    [(argumentProperty, ...)] ["Label"]
    [specialization of BaseType]
    [property ...]

This complete example uses types and the string stereotype supplied by the Base facility:

cmn
package com.example.customer

import org.joinedworkz.facilities.common.base

platform Base

/** ISO 4217-style code used by this application. */
type<string> CurrencyCode "Currency code"

type CustomerNumber specialization of String maxLength=30
  • type CurrencyCode declares a simple type.
  • <string> is a stereotype reference. string is defined by Base; it is not a built-in CMN primitive keyword.
  • The quoted text after the name is an optional label.
  • specialization of String derives the type from another simple type.
  • maxLength=30 is a property. Whether a property exists and what it means is defined by the selected profile and interpreted by its cartridges.
  • abstract is accepted before type. Its concrete generator effect depends on the selected platform.

Documentation, examples, stereotype lists, labels, and property values are described in Common declaration syntax. A simple-type example can supply the fallback value for fields of that type; the Base precedence is documented under OpenAPI documentation and examples.

2. Type arguments

A simple type may declare positional arguments by referring to properties defined by the profile:

cmn
package com.example.shared

import org.joinedworkz.facilities.common.base

platform Base

type ShortText(maxLength) specialization of String maxLength=80

type Address {
    street*: ShortText(120)
}

ShortText(maxLength) declares the argument position. ShortText(120) assigns 120 to that property for the field use. The type declaration determines the number and order of argument positions. The profile defines the referenced properties, including their value types and meaning. JoinedWorkz has no dedicated arity diagnostic, so uses should supply exactly the declared arguments.

3. Base simple types

The stable Base facility supplies these platform-neutral model types:

  • Any
  • String(maxLength)
  • Integer(maxDigits)
  • Long
  • Decimal(maxDigits, decimals)
  • Date
  • Time
  • Timestamp
  • Boolean
  • Binary
  • Id and Name, which specialize String
  • Text(maxLength), which specializes String

For new Long-based types, set the stable maxDigits property explicitly when a digit limit is required:

cmn
package com.example.shared

import org.joinedworkz.facilities.common.base

platform Base

type SequenceNumber specialization of Long maxDigits=19

These are model elements imported from Base, not reserved words. Another facility can provide additional types or interpret stereotypes differently.

The CMN grammar itself does not define a serialized wire representation for a simple type. Cartridges interpret the effective stereotypes and properties supplied by the selected profile. For example, Base explicitly declares its Timestamp with the time stereotype; the corresponding Base OpenAPI wire contract documents its ISO-8601 representation and the distinct behavior of a Long-based timestamp.

For new models use the canonical numeric properties min, max, maxDigits, and decimals. The former names minValue, maxValue, precision, and scale are deprecated compatibility aliases; see the upgrade guide.

4. Constants

const declares a named CMN property value:

cmn
package com.example.shared

const DEFAULT_LANGUAGE='EN'
const °AUDITING_ENABLED

The first constant has a string value. The ° form is a flag with the implicit Boolean value true. Supported value forms are listed in Common declaration syntax.

5. Facility and generator semantics

The declaration forms on this page are CMN grammar syntax. The Base types and the string stereotype are facility-provided. Concrete Java types, validation annotations, serialization formats, and other generated results are platform semantics; consult Facilities and platforms.

The SpringBoot example uses the same Base type model in a built project; see Build a CRUD backend.