MapStruct logo

MapStruct

A Java code generator for creating fast and type-safe bean mappings at compile time
51
44
+ 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.9K GitHub stars and 916 GitHub forks. Here’s a link to MapStruct's open source repository on GitHub

Who uses MapStruct?

Companies
10 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.
JavaScript
JavaScript is most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js or Apache CouchDB. It is a prototype-based, multi-paradigm scripting language that is dynamic,and supports object-oriented, imperative, and functional programming styles.
Git
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
GitHub
GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Over three million people use GitHub to build amazing things together.
See all alternatives

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