1 package de.japrost.jabudget.domain.account;
2
3 import java.util.Optional;
4
5
6
7
8 public class EntryBuilder {
9
10 private String accountId;
11 private String code;
12 private String subject;
13
14
15
16
17 public EntryBuilder() {
18 }
19
20
21
22
23
24
25 public EntryBuilder(final Entry example) {
26 if (example != null) {
27 this.accountId = example.getAccountId();
28 this.code = example.getCode();
29 this.subject = example.getSubject();
30 }
31 }
32
33
34
35
36
37
38 public static EntryBuilder builder() {
39 return new EntryBuilder();
40 }
41
42
43
44
45
46
47
48 public static EntryBuilder builder(Entry example) {
49 return new EntryBuilder(example);
50 }
51
52
53
54
55
56 public Entry build() {
57 final Entryin/account/Entry.html#Entry">Entry result = new Entry(accountId,code,subject);
58 return result;
59 }
60
61
62
63
64
65
66
67 public Optional<Entry> buildOptional() {
68
69 if (accountId == null || code == null || subject == null) {
70 return Optional.empty();
71 }
72 final Entryin/account/Entry.html#Entry">Entry result = new Entry(accountId,code,subject);
73 return Optional.of(result);
74 }
75
76
77
78
79 public void setAccountId(String accountId) {
80 this.accountId = accountId;
81 }
82
83
84
85
86 public void setCode(String code) {
87 this.code = code;
88 }
89
90
91
92
93 public void setSubject(String subject) {
94 this.subject = subject;
95 }
96 }