-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountDetails.java
42 lines (32 loc) · 1.17 KB
/
AccountDetails.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
package io.myfinbox.account.domain;
import jakarta.persistence.Embeddable;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import static io.myfinbox.shared.Guards.doesNotOverflow;
import static lombok.AccessLevel.PACKAGE;
@ToString
@Embeddable
@EqualsAndHashCode
@NoArgsConstructor(access = PACKAGE, force = true)
public final class AccountDetails implements Serializable {
public static final int MAX_LENGTH = 255;
private String firstName;
private String lastName;
public AccountDetails(String firstName, String lastName) {
if (!StringUtils.isBlank(firstName)) {
this.firstName = doesNotOverflow(firstName.trim(), MAX_LENGTH, "firstName overflow, max length allowed '%d'".formatted(MAX_LENGTH));
}
if (!StringUtils.isBlank(lastName)) {
this.lastName = doesNotOverflow(lastName.trim(), MAX_LENGTH, "lastName overflow, max length allowed '%d'".formatted(MAX_LENGTH));
}
}
public String firstName() {
return firstName;
}
public String lastName() {
return lastName;
}
}