profileShare

rasmusjy / tasteprint

Read-only snapshot

No repository description.

main default branch 169 files Expires Sep 13, 2026, 9:06 AM
Trip.java 1,736 bytes
1 package com.tasteprint.journey;
2
3 import java.time.Instant;
4 import java.time.LocalDate;
5 import java.util.UUID;
6
7 import jakarta.persistence.Column;
8 import jakarta.persistence.Entity;
9 import jakarta.persistence.Id;
10 import jakarta.persistence.Table;
11
12 @Entity
13 @Table(name = "trip")
14 class Trip {
15
16 @Id
17 private UUID id;
18
19 @Column(name = "user_id", nullable = false)
20 private UUID userId;
21
22 @Column(name = "destination_code", nullable = false, length = 2)
23 private String destinationCode;
24
25 @Column(nullable = false, length = 100)
26 private String city;
27
28 @Column(name = "starts_on", nullable = false)
29 private LocalDate startsOn;
30
31 @Column(name = "ends_on", nullable = false)
32 private LocalDate endsOn;
33
34 @Column(name = "created_at", nullable = false)
35 private Instant createdAt;
36
37 @Column(name = "updated_at", nullable = false)
38 private Instant updatedAt;
39
40 protected Trip() {
41 }
42
43 Trip(UUID id, UUID userId, String destinationCode, SaveTripRequest request, Instant now) {
44 this.id = id;
45 this.userId = userId;
46 this.destinationCode = destinationCode;
47 this.createdAt = now;
48 update(request, now);
49 }
50
51 void update(SaveTripRequest request, Instant now) {
52 this.city = request.city().trim();
53 this.startsOn = request.startsOn();
54 this.endsOn = request.endsOn();
55 this.updatedAt = now;
56 }
57
58 UUID id() {
59 return id;
60 }
61
62 UUID userId() {
63 return userId;
64 }
65
66 String destinationCode() {
67 return destinationCode;
68 }
69
70 String city() {
71 return city;
72 }
73
74 LocalDate startsOn() {
75 return startsOn;
76 }
77
78 LocalDate endsOn() {
79 return endsOn;
80 }
81 }
82