-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
432 lines (284 loc) · 20.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content="Hugo 0.17" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MapStruct – MapStruct</title>
<link rel="shortcut icon" href="https://mapstruct.github.io/mapstruct.org.new/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://mapstruct.github.io/mapstruct.org.new/css/uikit.gradient.css" />
<link rel="stylesheet" href="https://mapstruct.github.io/mapstruct.org.new/css/prettify.css" />
<link rel="stylesheet" href="https://mapstruct.github.io/mapstruct.org.new/css/font-awesome.css" />
<link rel="stylesheet" href="https://mapstruct.github.io/mapstruct.org.new/css/styles.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato" />
<script src="https://mapstruct.github.io/mapstruct.org.new/js/jquery-3.1.1.min.js"></script>
<script src="https://mapstruct.github.io/mapstruct.org.new/js/uikit.min.js"></script>
<script src="https://mapstruct.github.io/mapstruct.org.new/js/components/sticky.min.js"></script>
<script src="https://mapstruct.github.io/mapstruct.org.new/js/components/switcher.min.js"></script>
<script type="text/javascript" src="https://mapstruct.github.io/mapstruct.org.new/js/google-code-prettify/prettify.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body onload="prettyPrint()">
<nav class="uk-navbar uk-margin-large-bottom uk-navbar-attached">
<a class="uk-navbar-brand ms-navbar-brand uk-hidden-small" href="https://mapstruct.github.io/mapstruct.org.new/">MapStruct</a>
<ul class="uk-navbar-nav">
<li >
<a href="https://mapstruct.github.io/mapstruct.org.new/news/">News</a>
</li>
<li >
<a href="https://mapstruct.github.io/mapstruct.org.new/documentation/installation/">Documentation</a>
</li>
<li >
<a href="https://mapstruct.github.io/mapstruct.org.new/community/getting-help/">Community</a>
</li>
<li >
<a href="https://mapstruct.github.io/mapstruct.org.new/development/contributing/">Development</a>
</li>
</ul>
<div class="uk-navbar-flip uk-navbar-content uk-hidden-small">
<a class="github-button" href="https://github.com/mapstruct/mapstruct" data-icon="octicon-star" data-count-href="/mapstruct/mapstruct/stargazers" data-count-api="/repos/mapstruct/mapstruct#stargazers_count" data-count-aria-label="# stargazers on GitHub" aria-label="Star mapstruct/mapstruct on GitHub">Star</a>
<a class="github-button" href="https://github.com/mapstruct/mapstruct/fork" data-icon="octicon-repo-forked" data-count-href="/mapstruct/mapstruct/network" data-count-api="/repos/mapstruct/mapstruct#forks_count" data-count-aria-label="# forks on GitHub" aria-label="Fork mapstruct/mapstruct on GitHub">Fork</a>
</div>
</nav>
<div class="uk-container uk-container-center uk-margin-top uk-margin-large-bottom">
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<div class="uk-vertical-align uk-text-center ms-hero">
<div class="uk-vertical-align-middle uk-width-1-1">
<div class="ms-hero-logo-container">
<img src="images/mapstruct.png">
</div>
<p class="uk-text-large">Java bean mappings, the easy way!</p>
<p>
<a class="uk-button uk-button-primary uk-button-large" href="#get-started" data-uk-smooth-scroll>Get started <i class="uk-icon-angle-double-right"></i></a>
<a class="uk-button uk-button-large" href="https://mapstruct.github.io/mapstruct.org.new/documentation/installation/">Download <i class="uk-icon-angle-double-right"></i></a>
</p>
</div>
</div>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-medium-1-3 uk-row-first">
<h2 class="uk-h3">What is it?</h2>
<p>MapStruct is a code generator that greatly simplifies the implementation of mappings between Java bean types based on a convention over configuration approach.</p>
<p>The generated mapping code uses plain method invocations and thus is fast, type-safe and easy to understand.</p>
</div>
<div class="uk-width-medium-1-3">
<h2 class="uk-h3">Why?</h2>
<p>Multi-layered applications often require to map between different object models (e.g. entities and DTOs). Writing such mapping code is a tedious and error-prone task. MapStruct aims at simplifying this work by automating it as much as possible.</p>
<p>In contrast to other mapping frameworks MapStruct generates bean mappings at compile-time which ensures a high performance, allows for fast developer feedback and thorough error checking.</p>
</div>
<div class="uk-width-medium-1-3">
<h2 class="uk-h3">How?</h2>
<p>MapStruct is an annotation processor which is plugged into the Java compiler and can be used in command-line builds (Maven, Gradle etc.) as well as from within your preferred IDE.</p>
<p>MapStruct uses sensible defaults but steps out of your way when it comes to configuring or implementing special behavior.</p>
</div>
</div>
<hr/>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<h2>Latest News</h2>
<article class="uk-article article-compact">
<h3 class="uk-h3">MapStruct 1.1.0.Final seen in the wild!</h3>
<p class="uk-article-meta ms-article-author">
<time>November 22, 2016</time>
</p>
<div>
<p>I’m more than thrilled to report that MapStruct 1.1 Final has been spotted in the wild!
We grew that puppy for almost one year since the announcement of <a href="https://mapstruct.github.io/mapstruct.org.new/news/2015/11/25/mapstruct-1_0_Final-released.html">MapStruct 1.0</a>, so it was about time to let it go and put a final release into your hands.</p>
<p>Besides a plethora of bug fixes the 1.1 release adds many new features which should be very welcome to users of MapStruct 1.0:</p>
<ul>
<li>Nested target properties</li>
<li><code>@ValueMapping</code> annotation for enum mappings</li>
<li><code>@Named</code> annotation for simple string based mapping qualifiers</li>
<li>Support for custom <code>hasXyz()</code> methods to check the presence of source properties instead of null checks</li>
<li>Extended support of <code>java.text.NumberFormat</code> for Number types to String mapping</li>
<li>OSGi support</li>
<li>New built-in conversions around date/time type</li>
</ul>
<p></p>
</div>
<div>
<a href="https://mapstruct.github.io/mapstruct.org.new/news/2016-11-22-mapstruct-1_1_0_Final-seen-in-the-wild/">Read more...</a>
</div>
</article>
<article class="uk-article article-compact">
<h3 class="uk-h3">MapStruct 1.1.0.CR2 is out</h3>
<p class="uk-article-meta ms-article-author">
<time>November 08, 2016</time>
</p>
<div>
<p>It’s my pleasure to announce the second candidate release of MapStruct 1.1!</p>
<p>This release fixes several bugs discovered in the first CR but also adds some new built-in conversions around date/time types (e.g. from/to the <code>java.sql.*</code> types and between <code>java.time.LocalDate</code> and <code>java.util.Date</code>).
Normally, we wouldn’t add new functionality during the CR phase, but as these conversions have been contributed by community members (kudos to you!), we thought it’d be nice to put them into a release as soon as possible.</p>
<p></p>
</div>
<div>
<a href="https://mapstruct.github.io/mapstruct.org.new/news/2016-11-08-mapstruct-1_1_0_CR2-is-out/">Read more...</a>
</div>
</article>
<article class="uk-article article-compact">
<h3 class="uk-h3">MapStruct 1.1.0.CR1 released</h3>
<p class="uk-article-meta ms-article-author">
<time>September 07, 2016</time>
</p>
<div>
<p>MapStruct 1.1.0.CR1 consolodates the functionality introduced in the preceeding MapStruct 1.1.0 Beta releases. A number of bugs were solved:</p>
<ul>
<li>Automatic generation of an iterable mapping methods where the property selection is based on a qualfier.</li>
<li>Collection source getter null check to avoid NullPointExceptions.</li>
<li>Missing imports for generic types in collections in generated methods.</li>
<li>Removing redundant code from generated code when using nested source properties.</li>
<li>Optimisation when using enum constant (using an enum constant instead of a String conversion).</li>
<li>Fixing order for dependsOn.</li>
<li>Fixing an issue introduced 1.1.0.Beta2 that causes problems for the @MappingTarget in combination with @InheritInverseConfiguration</li>
</ul>
<p></p>
</div>
<div>
<a href="https://mapstruct.github.io/mapstruct.org.new/news/2016-09-07-mapstruct-1_1_0_CR1/">Read more...</a>
</div>
</article>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first uk-text-center">
<a class="uk-button uk-button-primary" href="https://mapstruct.github.io/mapstruct.org.new/news/">More News</a> |
<a class="uk-button uk-button-primary" href="https://mapstruct.github.io/mapstruct.org.new/news/index.xml">RSS Feed</a>
</div>
</div>
<hr/>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<h2 id="get-started">MapStruct in 2 Minutes</h2>
<div class="uk-grid">
<div class="uk-width-medium-1-3 uk-row-first">
<p>The following shows how map two objects using MapStruct.</p>
<p>Let's assume we have a class representing cars (e.g. a JPA entity) and an accompanying data transfer object (DTO).</p>
<p>Both types are rather similar, only the seat count attributes have different names and the type attribute is of a special enum type in the <code>Car</code> class but is a plain string in the DTO.</p>
</div>
<div class="uk-width-medium-2-3">
<ul class="uk-tab" data-uk-tab="{connect:'#listing-1'}">
<li class="uk-active"><a href="">Car.java</a></li>
<li><a href="">CarDto.java</a></li>
</ul>
<ul id="listing-1" class="uk-switcher uk-margin">
<li>
<pre class="prettyprint linenums">public class Car {
private String make;
private int numberOfSeats;
private CarType type;
//constructor, getters, setters etc.
}
</pre>
</li>
<li>
<pre class="prettyprint linenums">public class CarDto {
private String make;
private int seatCount;
private String type;
//constructor, getters, setters etc.
}</pre>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<h3>The mapper interface</h3>
<div class="uk-grid">
<div class="uk-width-medium-1-3 uk-row-first">
<p>To generate a mapper for creating a <code>CarDto</code> object out of a <code>Car</code> object, a mapper interface needs to be defined:</p>
</div>
<div class="uk-width-medium-2-3">
<ul class="uk-tab" data-uk-tab="{connect:'#listing-2'}">
<li class="uk-active"><a href="">CarMapper.java</a></li>
</ul>
<ul id="listing-2" class="uk-switcher uk-margin">
<li>
<pre class="prettyprint linenums prettyprinted" style=""><ol class="linenums"><li class="L0"><span class="lit">@Mapper</span><span class="pln"> </span><span class="uk-badge uk-badge-notification">1</span></li><li class="L1"><span class="kwd">public</span><span class="pln"> </span><span class="kwd">interface</span><span class="pln"> </span><span class="typ">CarMapper</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln"> </span></li><li class="L3"><span class="pln"> </span><span class="typ">CarMapper</span><span class="pln"> INSTANCE </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Mappers</span><span class="pun">.</span><span class="pln">getMapper</span><span class="pun">(</span><span class="pln"> </span><span class="typ">CarMapper</span><span class="pun">.</span><span class="kwd">class</span><span class="pln"> </span><span class="pun">);</span><span class="pln"> </span><span class="uk-badge uk-badge-notification">3</span></li><li class="L4"><span class="pln"> </span></li><li class="L5"><span class="pln"> </span><span class="lit">@Mapping</span><span class="pun">(</span><span class="pln">source </span><span class="pun">=</span><span class="pln"> </span><span class="str">"numberOfSeats"</span><span class="pun">,</span><span class="pln"> target </span><span class="pun">=</span><span class="pln"> </span><span class="str">"seatCount"</span><span class="pun">)</span></li><li class="L6"><span class="pln"> </span><span class="typ">CarDto</span><span class="pln"> carToCarDto</span><span class="pun">(</span><span class="typ">Car</span><span class="pln"> car</span><span class="pun">);</span><span class="pln"> </span><span class="uk-badge uk-badge-notification">2</span></li><li class="L7"><span class="pun">}</span></li></ol></pre>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-medium-1-3 uk-row-first">
<p>The <code>@Mapper</code> annotation <span class="uk-badge uk-badge-notification">1</span> marks the interface as mapping interface and lets the MapStruct processor kick in during compilation.</p>
<p>The actual mapping method <span class="uk-badge uk-badge-notification">2</span> expects the source object as parameter and returns the target object. Its name can be freely chosen.</p>
</div>
<div class="uk-width-medium-1-3">
<p>For attributes with different names in source and target object, the <code>@Mapping</code> annotation can be used to configure the names.</p>
<p>Where required and possible a type conversion will be executed for attributes with different types in source and target, e.g. the <code>type</code> attribute will be converted from the enumeration type into a string.</p>
</div>
<div class="uk-width-medium-1-3">
<p>Of course there can be multiple mapping methods in one interface, for all of which an implementation will be generated by MapStruct.</p>
<p>An instance of the interface implementation can be retrieved from the <code>Mappers</code> class. By convention, the interface declares a member <code>INSTANCE</code> <span class="uk-badge uk-badge-notification">3</span>, providing clients access to the mapper implementation.</p>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<h3>Using the mapper</h3>
<div class="uk-grid">
<div class="uk-width-medium-1-3 uk-row-first">
<p>Based on the mapper interface, clients can perform object mappings in a very easy and type-safe manner:</p>
</div>
<div class="uk-width-medium-2-3">
<ul class="uk-tab" data-uk-tab="{connect:'#listing-3'}">
<li class="uk-active"><a href="">CarMapperTest.java</a></li>
</ul>
<ul id="listing-3" class="uk-switcher uk-margin">
<li>
<pre class="prettyprint linenums">@Test
public void shouldMapCarToDto() {
//given
Car car = new Car( "Morris", 5, CarType.SEDAN );
//when
CarDto carDto = CarMapper.INSTANCE.carToCarDto( car );
//then
assertThat( carDto ).isNotNull();
assertThat( carDto.getMake() ).isEqualTo( "Morris" );
assertThat( carDto.getSeatCount() ).isEqualTo( 5 );
assertThat( carDto.getType() ).isEqualTo( "SEDAN" );
}</pre>
</li>
</ul>
</div>
</div>
</div>
</div>
<hr/>
<div class="uk-grid">
<div class="uk-width-medium-1-1 uk-row-first">
<h2>Tell me more!</h2>
<p>You like what you see? Then check out the <a href="https://mapstruct.github.io/mapstruct.org.new/documentation/reference-guide">reference documentation</a> to learn how to get started with MapStruct and which advanced features there are. In case you need help or want to propose a new feature just drop by on the <a href="https://groups.google.com/forum/?fromgroups#!forum/mapstruct-users">mapstruct-users</a> group.</p>
<p>You want to contribute to the development of MapStruct? That's great, <a href="https://mapstruct.github.io/mapstruct.org.new/development/contributing">this page</a> has all the information you need.</p>
</div>
</div>
</div>
<div class="ms-footer">
<div class="uk-container uk-container-center uk-vertical-align uk-height-1-1">
<div class="uk-vertical-align-middle uk-width-1-1">
<div class="uk-grid-small" >
<div class="uk-width-1-1 ">
<ul class="uk-subnav uk-subnav-line uk-flex-center ms-subnav-footer">
<li><a class="ms-link-footer" href="https://mapstruct.github.io/mapstruct.org.new/documentation/installation">Documentation</a></li>
<li><a class="ms-link-footer" href="https://github.com/mapstruct/mapstruct">Source Code</a></li>
<li><a class="ms-link-footer" href="https://twitter.com/GetMapStruct">Twitter</a></li>
<li><a class="ms-link-footer" href="https://plus.google.com/u/0/118070742567787866481">Google+</a></li>
</ul>
</div>
</div>
<div class="uk-grid">
<div class="uk-width-1-1 ms-subnav-footer">
© Gunnar Morling 2017
</div>
</div>
</div>
</div>
</div>
</body>
</html>