easytests.admin.dto.UserModelDto   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
c 0
b 0
f 0
loc 60
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map(UserModelInterface) 0 7 1
A mapInto(UserModelInterface) 0 11 2
1
package easytests.admin.dto;
2
3
import easytests.core.models.UserModelInterface;
4
import easytests.core.models.empty.ModelsListEmpty;
5
import javax.validation.constraints.*;
6
import lombok.Data;
7
import org.hibernate.validator.constraints.Email;
8
import org.hibernate.validator.constraints.NotEmpty;
9
10
11
/**
12
 * @author malinink
13
 */
14
@Data
15
public class UserModelDto {
16
    @Null
17
    private Integer id;
18
19
    @NotNull
20
    @NotEmpty
21
    @Size(min = 2, max = 30)
22
    private String firstName;
23
24
    @NotNull
25
    @NotEmpty
26
    @Size(min = 2, max = 30)
27
    private String lastName;
28
29
    @NotNull
30
    @NotEmpty
31
    @Size(min = 2, max = 30)
32
    private String surname;
33
34
    @NotNull
35
    @NotEmpty
36
    @Email
37
    @Size(min = 6, max = 30)
38
    private String email;
39
40
    @NotNull
41
    private String password;
42
43
    @NotNull
44
    private String passwordRepeat;
45
46
    @NotNull
47
    private Boolean isAdmin = false;
48
49
    @NotNull
50
    @Min(3)
51
    @Max(4)
52
    private Integer state = 3;
53
54
    public void mapInto(UserModelInterface userModel) {
55
        userModel.setFirstName(this.getFirstName());
56
        userModel.setLastName(this.getLastName());
57
        userModel.setSurname(this.getSurname());
58
        userModel.setEmail(this.getEmail());
59
        if (!this.getPassword().equals("")) {
60
            userModel.setPassword(this.getPassword());
61
        }
62
        userModel.setIsAdmin(this.getIsAdmin());
63
        userModel.setState(this.getState());
64
        userModel.setSubjects(new ModelsListEmpty());
65
    }
66
67
    public void map(UserModelInterface userModel) {
68
        this.setFirstName(userModel.getFirstName());
69
        this.setLastName(userModel.getLastName());
70
        this.setSurname(userModel.getSurname());
71
        this.setEmail(userModel.getEmail());
72
        this.setIsAdmin(userModel.getIsAdmin());
73
        this.setState(userModel.getState());
74
    }
75
}
76