1+ package ru .javawebinar .topjava .model ;
2+
3+ import java .util .Date ;
4+ import java .util .EnumSet ;
5+ import java .util .Set ;
6+
7+ import static ru .javawebinar .topjava .util .MealsUtil .DEFAULT_CALORIES_PER_DAY ;
8+
9+ public class User extends NamedEntity {
10+
11+ private String email ;
12+
13+ private String password ;
14+
15+ private boolean enabled = true ;
16+
17+ private Date registered = new Date ();
18+
19+ private Set <Role > roles ;
20+
21+ private int caloriesPerDay = DEFAULT_CALORIES_PER_DAY ;
22+
23+ public User () {
24+ }
25+
26+ public User (Integer id , String name , String email , String password , Role role , Role ... roles ) {
27+ this (id , name , email , password , DEFAULT_CALORIES_PER_DAY , true , EnumSet .of (role , roles ));
28+ }
29+
30+ public User (Integer id , String name , String email , String password , int caloriesPerDay , boolean enabled , Set <Role > roles ) {
31+ super (id , name );
32+ this .email = email ;
33+ this .password = password ;
34+ this .caloriesPerDay = caloriesPerDay ;
35+ this .enabled = enabled ;
36+ this .roles = roles ;
37+ }
38+
39+ public String getEmail () {
40+ return email ;
41+ }
42+
43+ public void setEmail (String email ) {
44+ this .email = email ;
45+ }
46+
47+ public void setPassword (String password ) {
48+ this .password = password ;
49+ }
50+
51+ public Date getRegistered () {
52+ return registered ;
53+ }
54+
55+ public void setRegistered (Date registered ) {
56+ this .registered = registered ;
57+ }
58+
59+ public void setEnabled (boolean enabled ) {
60+ this .enabled = enabled ;
61+ }
62+
63+ public int getCaloriesPerDay () {
64+ return caloriesPerDay ;
65+ }
66+
67+ public void setCaloriesPerDay (int caloriesPerDay ) {
68+ this .caloriesPerDay = caloriesPerDay ;
69+ }
70+
71+ public boolean isEnabled () {
72+ return enabled ;
73+ }
74+
75+ public Set <Role > getRoles () {
76+ return roles ;
77+ }
78+
79+ public String getPassword () {
80+ return password ;
81+ }
82+
83+ @ Override
84+ public String toString () {
85+ return "User (" +
86+ "id=" + id +
87+ ", email=" + email +
88+ ", name=" + name +
89+ ", enabled=" + enabled +
90+ ", roles=" + roles +
91+ ", caloriesPerDay=" + caloriesPerDay +
92+ ')' ;
93+ }
94+ }
0 commit comments