Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
## MapStruct
This module contains articles about MapStruct.
###Relevant Articles:
- [Quick Guide to MapStruct](https://www.baeldung.com/mapstruct)
- [Custom Mapper with MapStruct](https://www.baeldung.com/mapstruct-custom-mapper)
- [Using Multiple Source Objects with MapStruct](https://www.baeldung.com/mapstruct-multiple-source-objects)
- [Ignoring Unmapped Properties with MapStruct](https://www.baeldung.com/mapstruct-ignore-unmapped-properties)
+82
View File
@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>mapstruct</artifactId>
<name>mapstruct</name>
<version>1.0</version>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>mapstruct</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
<springframework.version>4.3.4.RELEASE</springframework.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<org.projectlombok.version>1.18.4</org.projectlombok.version>
<assertj.version>3.11.1</assertj.version>
</properties>
</project>
@@ -0,0 +1,12 @@
package com.baeldung.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CarDTO {
private int id;
private String name;
private FuelType fuelType;
}
@@ -0,0 +1,25 @@
package com.baeldung.dto;
public class CustomerDto {
private String forename;
private String surname;
public String getForename() {
return forename;
}
public CustomerDto setForename(String forename) {
this.forename = forename;
return this;
}
public String getSurname() {
return surname;
}
public CustomerDto setSurname(String surname) {
this.surname = surname;
return this;
}
}
@@ -0,0 +1,33 @@
package com.baeldung.dto;
public class DivisionDTO {
public DivisionDTO() {
}
public DivisionDTO(int id, String name) {
super();
this.id = id;
this.name = name;
}
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,42 @@
package com.baeldung.dto;
public class EmployeeDTO {
private int employeeId;
private String employeeName;
private DivisionDTO division;
private String employeeStartDt;
public int getEmployeeId() {
return employeeId;
}
public void setEmployeeId(int employeeId) {
this.employeeId = employeeId;
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public DivisionDTO getDivision() {
return division;
}
public void setDivision(DivisionDTO division) {
this.division = division;
}
public String getEmployeeStartDt() {
return employeeStartDt;
}
public void setEmployeeStartDt(String employeeStartDt) {
this.employeeStartDt = employeeStartDt;
}
}
@@ -0,0 +1,5 @@
package com.baeldung.dto;
public enum FuelType {
ELECTRIC, BIO_DIESEL
}
@@ -0,0 +1,33 @@
package com.baeldung.dto;
public class PersonDTO {
private String id;
private String name;
public PersonDTO() {
}
public PersonDTO(String id, String name) {
super();
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,24 @@
package com.baeldung.dto;
public class SimpleSource {
private String name;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
@@ -0,0 +1,23 @@
package com.baeldung.dto;
public class TransactionDTO {
private String uuid;
private Long totalInCents;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Long getTotalInCents() {
return totalInCents;
}
public void setTotalInCents(Long totalInCents) {
this.totalInCents = totalInCents;
}
}
@@ -0,0 +1,11 @@
package com.baeldung.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserBodyImperialValuesDTO {
private int inch;
private int pound;
}
@@ -0,0 +1,35 @@
package com.baeldung.entity;
public class Address {
private String street;
private String postalcode;
private String county;
public String getStreet() {
return street;
}
public Address setStreet(String street) {
this.street = street;
return this;
}
public String getPostalcode() {
return postalcode;
}
public Address setPostalcode(String postalcode) {
this.postalcode = postalcode;
return this;
}
public String getCounty() {
return county;
}
public Address setCounty(String county) {
this.county = county;
return this;
}
}
@@ -0,0 +1,4 @@
package com.baeldung.entity;
public class BioDieselCar extends Car {
}
@@ -0,0 +1,11 @@
package com.baeldung.entity;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Car {
private int id;
private String name;
}
@@ -0,0 +1,25 @@
package com.baeldung.entity;
public class Customer {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public Customer setFirstName(String firstName) {
this.firstName = firstName;
return this;
}
public String getLastName() {
return lastName;
}
public Customer setLastName(String lastName) {
this.lastName = lastName;
return this;
}
}
@@ -0,0 +1,55 @@
package com.baeldung.entity;
public class DeliveryAddress {
private String forename;
private String surname;
private String street;
private String postalcode;
private String county;
public String getForename() {
return forename;
}
public DeliveryAddress setForename(String forename) {
this.forename = forename;
return this;
}
public String getSurname() {
return surname;
}
public DeliveryAddress setSurname(String surname) {
this.surname = surname;
return this;
}
public String getStreet() {
return street;
}
public DeliveryAddress setStreet(String street) {
this.street = street;
return this;
}
public String getPostalcode() {
return postalcode;
}
public DeliveryAddress setPostalcode(String postalcode) {
this.postalcode = postalcode;
return this;
}
public String getCounty() {
return county;
}
public DeliveryAddress setCounty(String county) {
this.county = county;
return this;
}
}
@@ -0,0 +1,33 @@
package com.baeldung.entity;
public class Division {
public Division() {
}
public Division(int id, String name) {
super();
this.id = id;
this.name = name;
}
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,4 @@
package com.baeldung.entity;
public class ElectricCar extends Car {
}
@@ -0,0 +1,44 @@
package com.baeldung.entity;
import java.util.Date;
public class Employee {
private int id;
private String name;
private Division division;
private Date startDt;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Division getDivision() {
return division;
}
public void setDivision(Division division) {
this.division = division;
}
public Date getStartDt() {
return startDt;
}
public void setStartDt(Date startDt) {
this.startDt = startDt;
}
}
@@ -0,0 +1,33 @@
package com.baeldung.entity;
public class Person {
private String id;
private String name;
public Person() {
}
public Person(String id, String name) {
super();
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,24 @@
package com.baeldung.entity;
public class SimpleDestination {
private String name;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
@@ -0,0 +1,23 @@
package com.baeldung.entity;
import java.math.BigDecimal;
import java.util.UUID;
public class Transaction {
private Long id;
private String uuid = UUID.randomUUID().toString();
private BigDecimal total;
public Long getId() {
return id;
}
public String getUuid() {
return uuid;
}
public BigDecimal getTotal() {
return total;
}
}
@@ -0,0 +1,11 @@
package com.baeldung.entity;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserBodyValues {
private double kilogram;
private double centimeter;
}
@@ -0,0 +1,15 @@
package com.baeldung.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import com.baeldung.dto.CarDTO;
import com.baeldung.entity.Car;
@Mapper
public interface CarMapper {
CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
CarDTO carToCarDTO(Car car);
}
@@ -0,0 +1,32 @@
package com.baeldung.mapper;
import org.mapstruct.AfterMapping;
import org.mapstruct.BeforeMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import com.baeldung.dto.CarDTO;
import com.baeldung.dto.FuelType;
import com.baeldung.entity.BioDieselCar;
import com.baeldung.entity.Car;
import com.baeldung.entity.ElectricCar;
@Mapper
public abstract class CarsMapper {
@BeforeMapping
protected void enrichDTOWithFuelType(Car car, @MappingTarget CarDTO carDto) {
if (car instanceof ElectricCar)
carDto.setFuelType(FuelType.ELECTRIC);
if (car instanceof BioDieselCar)
carDto.setFuelType(FuelType.BIO_DIESEL);
}
@AfterMapping
protected void convertNameToUpperCase(@MappingTarget CarDTO carDto) {
carDto.setName(carDto.getName().toUpperCase());
}
public abstract CarDTO toCarDto(Car car);
}
@@ -0,0 +1,15 @@
package com.baeldung.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import com.baeldung.dto.CustomerDto;
import com.baeldung.entity.Customer;
@Mapper
public interface CustomerDtoMapper {
@Mapping(source = "firstName", target = "forename")
@Mapping(source = "lastName", target = "surname")
CustomerDto from(Customer customer);
}
@@ -0,0 +1,24 @@
package com.baeldung.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import com.baeldung.entity.Address;
import com.baeldung.entity.Customer;
import com.baeldung.entity.DeliveryAddress;
@Mapper
public interface DeliveryAddressMapper {
@Mapping(source = "customer.firstName", target = "forename")
@Mapping(source = "customer.lastName", target = "surname")
@Mapping(source = "address.street", target = "street")
@Mapping(source = "address.postalcode", target = "postalcode")
@Mapping(source = "address.county", target = "county")
DeliveryAddress from(Customer customer, Address address);
@Mapping(source = "address.postalcode", target = "postalcode")
@Mapping(source = "address.county", target = "county")
DeliveryAddress updateAddress(@MappingTarget DeliveryAddress deliveryAddress, Address address);
}
@@ -0,0 +1,30 @@
package com.baeldung.mapper;
import com.baeldung.dto.DivisionDTO;
import com.baeldung.dto.EmployeeDTO;
import com.baeldung.entity.Division;
import com.baeldung.entity.Employee;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import java.util.List;
@Mapper
public interface EmployeeMapper {
@Mappings({ @Mapping(target = "employeeId", source = "entity.id"), @Mapping(target = "employeeName", source = "entity.name"), @Mapping(target = "employeeStartDt", source = "entity.startDt", dateFormat = "dd-MM-yyyy HH:mm:ss") })
EmployeeDTO employeeToEmployeeDTO(Employee entity);
@Mappings({ @Mapping(target = "id", source = "dto.employeeId"), @Mapping(target = "name", source = "dto.employeeName"), @Mapping(target = "startDt", source = "dto.employeeStartDt", dateFormat = "dd-MM-yyyy HH:mm:ss") })
Employee employeeDTOtoEmployee(EmployeeDTO dto);
DivisionDTO divisionToDivisionDTO(Division entity);
Division divisionDTOtoDivision(DivisionDTO dto);
List<Employee> convertEmployeeDTOListToEmployeeList(List<EmployeeDTO> list);
List<EmployeeDTO> convertEmployeeListToEmployeeDTOList(List<Employee> list);
}
@@ -0,0 +1,17 @@
package com.baeldung.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import com.baeldung.dto.PersonDTO;
import com.baeldung.entity.Person;
@Mapper
public interface PersonMapper {
PersonMapper INSTANCE = Mappers.getMapper(PersonMapper.class);
@Mapping(target = "id", source = "person.id", defaultExpression = "java(java.util.UUID.randomUUID().toString())")
PersonDTO personToPersonDTO(Person person);
}
@@ -0,0 +1,13 @@
package com.baeldung.mapper;
import org.mapstruct.Qualifier;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface PoundToKilogramMapper {}

Some files were not shown because too many files have changed in this diff Show More