forked from microservices-patterns/ftgo-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Consumer.java
50 lines (38 loc) · 1.05 KB
/
Consumer.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
package net.chrisrichardson.ftgo.consumerservice.domain;
import io.eventuate.tram.events.publisher.ResultWithEvents;
import net.chrisrichardson.ftgo.common.Money;
import net.chrisrichardson.ftgo.common.PersonName;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "consumers")
@Access(AccessType.FIELD)
public class Consumer {
@Id
@GeneratedValue
private Long id;
@Embedded
private PersonName name;
private Consumer() {
}
public Consumer(PersonName name) {
this.name = name;
}
public void validateOrderByConsumer(Money orderTotal) {
// implement some business logic
}
public Long getId() {
return id;
}
public PersonName getName() {
return name;
}
public static ResultWithEvents<Consumer> create(PersonName name) {
return new ResultWithEvents<>(new Consumer(name), new ConsumerCreated());
}
}