From 81f82a54a5d1e233ea7fb15237c61aca5fd8e237 Mon Sep 17 00:00:00 2001 From: tomoya-yokota Date: Thu, 28 Jun 2018 19:52:33 +0900 Subject: [PATCH] Document of sample code is broken. --- .../src/main/asciidoc/mapstruct-reference-guide.asciidoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/src/main/asciidoc/mapstruct-reference-guide.asciidoc b/documentation/src/main/asciidoc/mapstruct-reference-guide.asciidoc index c79eb6efd..0efe2c8da 100644 --- a/documentation/src/main/asciidoc/mapstruct-reference-guide.asciidoc +++ b/documentation/src/main/asciidoc/mapstruct-reference-guide.asciidoc @@ -2017,10 +2017,10 @@ The same warnings and restrictions apply to default expressions that apply to ex The example below demonstrates how two source properties can be mapped to one target: .Mapping method using a default expression -=== +==== [source, java, linenums] [subs="verbatim,attributes"] ---- +---- imports java.util.UUID; @Mapper( imports = UUID.class ) @@ -2031,8 +2031,8 @@ public interface SourceTargetMapper { @Mapping(target="id", source="sourceId", defaultExpression = "java( UUID.randomUUID().toString() )") Target sourceToTarget(Source s); } ---- -=== +---- +==== The example demonstrates how to use defaultExpression to set an `ID` field if the source field is null, this could be used to take the existing `sourceId` from the source object if it is set, or create a new `Id` if it isn't. Please note that the fully qualified package name is specified because MapStruct does not take care of the import of the `UUID` class (unless it’s used otherwise explicitly in the `SourceTargetMapper`). This can be resolved by defining imports on the @Mapper annotation ((see <>).