Guest User

Untitled

a guest
Oct 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package com.gmendozag.co.Entity;
  2.  
  3. import javax.persistence.*;
  4. import javax.validation.constraints.NotNull;
  5. import javax.validation.constraints.Pattern;
  6. import javax.validation.constraints.Size;
  7.  
  8. @Entity
  9. public class Cliente {
  10.  
  11. public Cliente() { }
  12.  
  13. public Cliente(String nombre, String apellido) {
  14. this.nombre=nombre;
  15. this.apellido=apellido;
  16. }
  17.  
  18. public Cliente(String nombre, String apellido, String telefono, String email) {
  19. this.nombre = nombre;
  20. this.apellido = apellido;
  21. this.telefono=telefono;
  22. this.email=email;
  23. }
  24.  
  25. @Id
  26. @GeneratedValue(strategy = GenerationType.AUTO)
  27. private Long id;
  28.  
  29. @NotNull(message = "Nombre Requerido")
  30. @Size(min = 3, max = 50, message = "El nombre debe estar en el rango, como minimo 3 y como maximo 50 caracteres")
  31. private String nombre;
  32.  
  33. private String apellido;
  34.  
  35. private String telefono;
  36.  
  37. @NotNull(message = "Email es Requerido")
  38. @Pattern(regexp = ".+@.+\\.[a-z]+", message = "\n" + "Debe ser un correo electrónico válido")
  39. private String email;
  40.  
  41. public Long getId() { return id; }
  42.  
  43. public void setId(Long id) { this.id = id; }
  44.  
  45. public String getNombre() { return nombre; }
  46.  
  47. public void setNombre(String nombre) { this.nombre = nombre; }
  48.  
  49. public String getApellido() { return apellido; }
  50.  
  51. public void setApellido(String apellido) { this.apellido = apellido; }
  52.  
  53. public String getTelefono() { return telefono; }
  54.  
  55. public void setTelefono(String telefono) { this.telefono = telefono; }
  56.  
  57. public String getEmail() { return email; }
  58.  
  59. public void setEmail(String email) { this.email = email; }
  60.  
  61. @Override
  62. public String toString() {
  63. return "Cliente{" + "id=" + id + ", nombre='" + nombre + '\'' + ", apellido='" + apellido + '\'' + ", telefono='" + telefono + '\'' + ", email='" + email + '\'' + '}';
  64. }
  65.  
  66. @Override
  67. public boolean equals(Object obj) {
  68. if (this == obj) {
  69. return true;
  70. }
  71. if (this.id == null) {
  72. return false;
  73. }
  74. if (obj instanceof Cliente && obj.getClass().equals(getClass())) {
  75. return this.id.equals(((Cliente) obj).id);
  76. }
  77. return false;
  78. }
  79. @Override
  80. public int hashCode() {
  81. int hash = 5;
  82. hash = 43 * hash + (id == null ? 0 : id.hashCode());
  83. return hash;
  84. }
  85. }
Add Comment
Please, Sign In to add comment