-
Notifications
You must be signed in to change notification settings - Fork 104
/
AddressDto.java
61 lines (46 loc) · 1.42 KB
/
AddressDto.java
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
package com.lakesidemutual.customercore.interfaces.dtos.customer;
import javax.validation.constraints.NotEmpty;
import com.lakesidemutual.customercore.domain.customer.Address;
/**
* The AddressDto represents the message payload to change a customer's address. This is an example of the <a href=
* "https://www.microservice-api-patterns.org/patterns/structure/representationElements/AtomicParameterList">Atomic Parameter List</a> pattern.
*/
public class AddressDto {
@NotEmpty
private String streetAddress;
@NotEmpty
private String postalCode;
@NotEmpty
private String city;
public AddressDto() {
}
public AddressDto(String streetAddress, String postalCode, String city) {
this.streetAddress = streetAddress;
this.postalCode = postalCode;
this.city = city;
}
public static AddressDto fromDomainObject(Address address) {
return new AddressDto(address.getStreetAddress(), address.getPostalCode(), address.getCity());
}
public Address toDomainObject() {
return new Address(streetAddress, postalCode, city);
}
public String getStreetAddress() {
return streetAddress;
}
public String getPostalCode() {
return postalCode;
}
public String getCity() {
return city;
}
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public void setCity(String city) {
this.city = city;
}
}