Skip to main content
ElastiCORE 3.0 is a release candidate: 3.0.261022-rc1 on Maven Central. Projects on the 2.2 line: see the 2.2 documentation.
Version: 3.0

Enumerations

model/enum.yml
enumeration:
OrderStatus:
meta: enum @db(code) @json(code) -- order status
fields:
code: string(3) @code
label: string(20)
enum:
PLACED: PLC, Placed
SHIPPED: SHP, Shipped
CANCELLED: CAN, Cancelled
AnnotationMeans
@db(field)the field stored in the database
@json(field)the field sent in JSON
@code (on a field)stored and sent - @db and @json at once

Each constant lists its field values in order (PLC, Placed). The database holds PLC, the JSON says "PLC", and the generated TypeScript has both the codes and the labels (OrderStatusLabel).

  • Lifecycles use the constant names, not the codes: ship: PLACED -> SHIPPED. See Lifecycle.
  • Metrics compare with constant names too (where status != CANCELLED); the export turns them into the stored value ('CAN'). See Metrics.
  • An unknown code in a request answers 400 with a field error (Unknown CreditCardType code: DINERS).
  • Spring Boot 4: enums are generated with @JsonValue + @JsonCreator, which Jackson 3 reads; see Spring Boot 3 and 4.
  • In the Ossie export an enum field is datatype: String with ai_context: "Codes: PLC = Placed, SHP = Shipped, CAN = Cancelled".