File tree Expand file tree Collapse file tree
mapstruct-protobuf3/usage/src
main/java/org/mapstruct/example/mapper
test/java/org/mapstruct/example Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424import org .mapstruct .MappingConstants ;
2525import org .mapstruct .NullValueCheckStrategy ;
2626import org .mapstruct .ValueMapping ;
27- import org .mapstruct .example .mapper .UserMapper .BuilderFactory ;
2827import org .mapstruct .example .protobuf .Permission ;
2928import org .mapstruct .example .protobuf .User ;
3029import org .mapstruct .example .protobuf .UserProtos .PermissionDTO ;
3433/**
3534 * @author Thomas Kratz
3635 */
37- @ Mapper (uses = BuilderFactory .class ,
38- collectionMappingStrategy = CollectionMappingStrategy .ADDER_PREFERRED ,
36+ @ Mapper (collectionMappingStrategy = CollectionMappingStrategy .ADDER_PREFERRED ,
3937 nullValueCheckStrategy = NullValueCheckStrategy .ALWAYS )
4038public interface UserMapper {
4139
4240 UserMapper INSTANCE = Mappers .getMapper (UserMapper .class );
4341
4442
4543 @ Mapping (source = "permissions" , target = "permissionsList" )
46- UserDTO . Builder map (User user );
44+ UserDTO map (User user );
4745
4846 @ Mapping (source = "permissionsList" , target = "permissions" )
4947 User map (UserDTO userDTO );
@@ -53,10 +51,4 @@ public interface UserMapper {
5351
5452 PermissionDTO map (Permission perm );
5553
56-
57- class BuilderFactory {
58- UserDTO .Builder builder () {
59- return UserDTO .newBuilder ();
60- }
61- }
6254}
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ public void test() throws InvalidProtocolBufferException {
4040 user .setEmail ("test" );
4141 user .getPermissions ().add (Permission .ADMIN );
4242
43- UserDTO . Builder dto = UserMapper .INSTANCE .map (user );
44- UserDTO deserialized = UserDTO .parseFrom (dto .build (). toByteArray ());
43+ UserDTO dto = UserMapper .INSTANCE .map (user );
44+ UserDTO deserialized = UserDTO .parseFrom (dto .toByteArray ());
4545 User back = UserMapper .INSTANCE .map (deserialized );
4646
4747 Assert .assertEquals ("" , back .getId ());
@@ -57,8 +57,8 @@ public void testNulls() throws InvalidProtocolBufferException {
5757 user .setEmail ("test" );
5858 user .getPermissions ().add (Permission .ADMIN );
5959
60- UserDTO . Builder dto = UserMapper .INSTANCE .map (user );
61- UserDTO deserialized = UserDTO .parseFrom (dto .build (). toByteArray ());
60+ UserDTO dto = UserMapper .INSTANCE .map (user );
61+ UserDTO deserialized = UserDTO .parseFrom (dto .toByteArray ());
6262 User back = UserMapper .INSTANCE .map (deserialized );
6363
6464 Assert .assertEquals ("" , back .getId ());
You can’t perform that action at this time.
0 commit comments