MapStruct logo

MapStruct

A Java code generator for creating fast and type-safe bean mappings at compile time
49
39
+ 1
1

What is MapStruct?

It is a code generator that greatly simplifies the implementation of mappings between Java bean types based on a convention over configuration approach. The generated mapping code uses plain method invocations and thus is fast, type-safe and easy to understand.
MapStruct is a tool in the Java Tools category of a tech stack.
MapStruct is an open source tool with 6.4K GitHub stars and 872 GitHub forks. Here’s a link to MapStruct's open source repository on GitHub

Who uses MapStruct?

Companies
8 companies reportedly use MapStruct in their tech stacks, including Backbase, pashabank.digital, and ohmycompany.

Developers
40 developers on StackShare have stated that they use MapStruct.
Pros of MapStruct
1
Abstraction of the object conversion

MapStruct's Features

  • Mapping (immutable) objects using builders
  • Enhanced and more flexible update method (@MappingTarget) handling
  • Constructor injection for Annotation Based component models
  • Source policy for unmapped source properties (unmappedSourcePolicy)
  • Support for defaultExpression
  • Limit mapping only to explicitly defined mappings
  • Performance improvement of constant / defaultValue primitive to String mappings
  • Warnings for precision loss

MapStruct Alternatives & Comparisons

What are some alternatives to MapStruct?
Lombok
It is a java library that automatically plugs into your editor and build tools, spicing up your java. Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.
Jackson
It is a suite of data-processing tools for Java (and the JVM platform), including the flagship streaming JSON parser / generator library, matching data-binding library (POJOs to and from JSON) and additional data format modules to process data encoded in Avro, BSON, CBOR, CSV, Smile, (Java) Properties, Protobuf, XML or YAML; and even the large set of data format modules to support data types of widely used data types such as Guava, Joda.
guava
The Guava project contains several of Google's core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.
Java 8
It is a revolutionary release of the world’s no 1 development platform. It includes a huge upgrade to the Java programming model and a coordinated evolution of the JVM, Java language, and libraries. Java 8 includes features for productivity, ease of use, improved polyglot programming, security and improved performance.
Apache FreeMarker
It is a "template engine"; a generic tool to generate text output (anything from HTML to auto generated source code) based on templates. It's a Java package, a class library for Java programmers.
See all alternatives

MapStruct's Followers
40 developers follow MapStruct to keep up with related blogs and decisions.