cz.muni.pa165.carparkapp.dto.EmployeeDTO.java Source code

Java tutorial

Introduction

Here is the source code for cz.muni.pa165.carparkapp.dto.EmployeeDTO.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.pa165.carparkapp.dto;

import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.Size;
import org.apache.commons.codec.digest.DigestUtils;

/**
 *
 * @author Martin
 */
public class EmployeeDTO implements Cloneable {
    private int id = -1;

    @Size(min = 1, max = 12)
    private String firstName;

    @Size(min = 1, max = 12)
    private String lastName;

    @Size(min = 1, max = 20)
    private String address;

    private String birthNumber;

    @Size(min = 1, max = 15)
    private String telNumber;

    private String userName;

    private String password;

    private String role;

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if (password.equals(this.password)) {
            return;
        }

        this.password = DigestUtils.shaHex(password);
    }

    private List<LoanDTO> loans = new ArrayList<>();

    public EmployeeDTO() {
    }

    public EmployeeDTO(int id, String firstName, String lastName, String address, String birthNumber,
            String telNumber, List<LoanDTO> loans) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.address = address;
        this.birthNumber = birthNumber;
        this.telNumber = telNumber;
        this.loans = loans;
    }

    public EmployeeDTO(String firstName, String lastName, String address, String birthNumber, String telNumber,
            List<LoanDTO> loans) {
        this(-1, firstName, lastName, address, birthNumber, telNumber, loans);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBirthNumber() {
        return birthNumber;
    }

    public void setBirthNumber(String birthNumber) {
        this.birthNumber = birthNumber;
    }

    public String getTelNumber() {
        return telNumber;
    }

    public void setTelNumber(String telNumber) {
        this.telNumber = telNumber;
    }

    public List<LoanDTO> getLoans() {
        return loans;
    }

    public void setLoans(List<LoanDTO> loans) {
        this.loans = loans;
    }

    @Override
    public String toString() {
        return "EmployeeDTO{" + "id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", address="
                + address + ", birthNumber=" + birthNumber + ", telNumber=" + telNumber + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + this.id;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EmployeeDTO other = (EmployeeDTO) obj;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }
}