GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use switch Expressions for JDK13 and newer · Issue #4062 · mapstruct/mapstruct

Use switch Expressions for JDK13 and newer #4062

New issue
Copy link
New issue
Copy link
Closed
Closed
Use switch Expressions for JDK13 and newer#4062
Copy link
Labels
featurehack.commit.push

Description

@hduelme
hduelme
opened on Jun 3, 2026
Issue body actions

Use case

Switch Expressions added in JDK13 give a better way of writing switches.
Currently value mappings uses normal switches only.

Generated Code

Instead of generating:

        switch ( b ) {
            case "A": a = ValueMapper.A.A;
            break;
            case "B": a = ValueMapper.A.B;
            break;
            default: throw new IllegalArgumentException( "Unexpected enum constant: " + b );
        }

the generated output could be

        ValueMapper.A a = switch (b) {
            case "A" -> A.A;
            case "B" -> A.B;
            default -> throw new IllegalArgumentException("Unexpected enum constant: " + b);
        };

For enums constants the default branch is not needed.

Possible workarounds

No response

MapStruct Version

1.6.3

Activity

  1. hduelme
    added
    feature
    hack.commit.push
    on Jun 3, 2026
  2. hduelme
    added a commit that references this issue on Jun 14, 2026

    #4062 Added the new switch expression usage for jdk equal or greater …

    9376d42
  3. hduelme commented on Jun 14, 2026

    @hduelme
    hduelme
    on Jun 14, 2026
    ContributorAuthor
    More actions

    Implemented in #4065

  4. hduelme
    closed this as completedon Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurehack.commit.push

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.