-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreference.java
38 lines (30 loc) · 978 Bytes
/
Preference.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
package io.myfinbox.account.domain;
import jakarta.persistence.Embeddable;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.io.Serializable;
import java.time.ZoneId;
import java.util.Currency;
import static io.myfinbox.shared.Guards.notNull;
import static lombok.AccessLevel.PACKAGE;
@ToString
@Embeddable
@EqualsAndHashCode
@NoArgsConstructor(access = PACKAGE, force = true)
public final class Preference implements Serializable {
private final String currency;
private final String zoneId;
public Preference(Currency currency, ZoneId zoneId) {
notNull(currency, "currency cannot be null.");
notNull(zoneId, "zoneId cannot be null.");
this.currency = currency.getCurrencyCode();
this.zoneId = zoneId.getId();
}
public Currency currency() {
return Currency.getInstance(currency);
}
public ZoneId zoneId() {
return ZoneId.of(zoneId);
}
}