Page tree
Skip to end of metadata
Go to start of metadata


Quickstart

MAGELLAN-8 - Getting issue details... STATUS

https://mapstruct.org/documentation/1.3/reference/html/


1.3.0.Final
pom.xml

https://mapstruct.org/documentation/installation/

<!-- org.mapstruct.version>1.4.1.Final</org.mapstruct.version-->
<dependency>
  <groupId>org.mapstruct</groupId>
  <artifactId>mapstruct</artifactId>
  <version>${org.mapstruct.version}</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Code
@Mapper
public interface PayloadRequestMapper {
	@Mapping(source = "message", target = "text")
	PayloadEntityImpl payloadRequestToPayloadEntity(PayloadRequestImpl payloadRequest);}


@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2020-12-13T17:30:29-0500",
comments = "version: 1.3.0.Final, compiler: Eclipse JDT (IDE) 1.3.1100.v20200828-0941, environment: Java 11.0.8 (Oracle Corporation)"
)
public class PayloadRequestMapperImpl implements PayloadRequestMapper {

@Override
public PayloadEntityImpl payloadRequestToPayloadEntity(PayloadRequestImpl payloadRequest) {
  if ( payloadRequest == null ) {
    return null;
  }
  PayloadEntityImpl payloadEntityImpl = new PayloadEntityImpl();
  payloadEntityImpl.setText( payloadRequest.getMessage() );
  payloadEntityImpl.setId( payloadRequest.getId() );
  return payloadEntityImpl;
}

@Test
public void testMapper() {
  String expected = "a Message";
  PayloadRequest request = new PayloadRequestImpl();
  request.setId(1L);
  request.setSequence(1L);
  request.setMessage(expected);
  PayloadEntity entity = payloadRequestMapper.payloadRequestToPayloadEntity(request);
  Assert.assertNotNull(entity);
  Assert.assertEquals(expected, entity.getText());
}


MapStruct Examples

  • No labels