Examples / Myra Codec

Portfolio Builder

myra-codec-portfolio

Encode a portfolio with nested legs, repeated tags, optional comments, and binary attachments.

Codec Gradle Java 25 View source

Overview

This example demonstrates nested, repeated fields by building a portfolio that contains multiple legs. It also shows repeated string tags, binary attachments, and an optional comment field.

Clone and run

  1. Install Java 25 and Git, then confirm the toolchain.

    java --version
  2. Clone the examples repository.

    git clone https://github.com/mvp-express/examples.git
  3. Move into the portfolio example folder.

    cd examples/myra-codec-portfolio
  4. Generate sources and the lock file.

    ./gradlew codegen
  5. Run the demo app.

    ./gradlew run

If you are on Windows, use gradlew.bat instead of ./gradlew.

Concepts highlighted

  • Nested repeated messages for portfolio legs.
  • Enum decoding via Side and presence checks for optional comment.
  • Repeated string tags accessed with Utf8View for zero copy reads.
  • Binary attachments encoded as byte arrays and decoded from MemorySegments.
  • Builder and flyweight workflow over pooled MemorySegments.

Files to explore

  • src/main/resources/schemas/portfolio.myra.yml
  • src/main/java/express/mvp/myra/codec/examples/PortfolioExampleApp.java

At a glance

  • Type: Myra Codec
  • Build: Gradle
  • Main: PortfolioExampleApp
  • Schema: portfolio.myra.yml
  • Output: Console logs
Open on GitHub

Learn more

Need more schema guidance? Start with the codec docs.

Myra Codec Docs