11package org .launchcode .codingevents .models ;
22
33import jakarta .persistence .Entity ;
4- import jakarta .persistence .GeneratedValue ;
5- import jakarta .persistence .Id ;
64import jakarta .validation .constraints .Email ;
75import jakarta .validation .constraints .NotBlank ;
86import jakarta .validation .constraints .Size ;
97
10- import java .util .Objects ;
8+ /**
9+ * Created by Chris Bay
10+ */
1111@ Entity
12- public class Event extends AbstractEntity {
13- /* @Id
14- @GeneratedValue
15- private int id;
16- private static int nextId = 1;
17- @NotBlank
18- @Size(min = 3, max = 50, message = "Name must be between 3 and 50 characters")
19- private String name;
20- @Size(max = 500, message = "Description too long!")
21- private String description;
12+ public class Event extends AbstractEntity {
2213
23- @Email(message = "Invalid email. Try again.")
24- private String contactEmail;
14+ @ NotBlank (message = "Name is required" )
15+ @ Size (min = 3 , max = 50 , message = "Name must be between 3 and 50 characters" )
16+ private String name ;
2517
26- private EventType type;
18+ @ Size (max = 500 , message = "Description too long!" )
19+ private String description ;
2720
21+ @ NotBlank (message = "Email is required" )
22+ @ Email (message = "Invalid email. Try again." )
23+ private String contactEmail ;
2824
25+ private EventType type ;
2926
3027 public Event (String name , String description , String contactEmail , EventType type ) {
31- this();
3228 this .name = name ;
3329 this .description = description ;
3430 this .contactEmail = contactEmail ;
3531 this .type = type ;
36-
37- }
38- public Event() {
39- this.id = nextId;
40- nextId++;
41- }
42- public EventType getType() {
43- return type;
4432 }
4533
46- public void setType(EventType type) {
47- this.type = type;
34+ public Event () {}
35+
36+ public String getName () {
37+ return name ;
4838 }
49- public String getName() {
50- return name;
51- }
5239
53- public void setName(String name) {
54- this.name = name;
55- }
40+ public void setName (String name ) {
41+ this .name = name ;
42+ }
5643
5744 public String getDescription () {
5845 return description ;
@@ -62,10 +49,6 @@ public void setDescription(String description) {
6249 this .description = description ;
6350 }
6451
65- public int getId() {
66- return id;
67- }
68-
6952 public String getContactEmail () {
7053 return contactEmail ;
7154 }
@@ -74,21 +57,17 @@ public void setContactEmail(String contactEmail) {
7457 this .contactEmail = contactEmail ;
7558 }
7659
77- @Override
78- public String toString() {
79- return name;
80- }
60+ public EventType getType () {
61+ return type ;
62+ }
8163
82- @Override
83- public boolean equals(Object o) {
84- if (this == o) return true;
85- if (o == null || getClass() != o.getClass()) return false;
86- Event event = (Event) o;
87- return id == event.id;
64+ public void setType (EventType type ) {
65+ this .type = type ;
8866 }
8967
9068 @ Override
91- public int hashCode() {
92- return Objects.hash(id);
93- }*/
94- }
69+ public String toString () {
70+ return name ;
71+ }
72+
73+ }
0 commit comments